Updated OpenCore-Boot.sh for macOS Sonoma support and added OpenCore-Boot-NoUI.sh for background VM startup.

This commit is contained in:
Steffen70 2024-06-12 18:39:38 +02:00
parent 326053dd61
commit cdf6ceed4b
5 changed files with 2110 additions and 6 deletions

50
OpenCore-Boot-NoUI.sh Executable file
View File

@ -0,0 +1,50 @@
#!/usr/bin/env bash
MY_OPTIONS="+ssse3,+sse4.2,+popcnt,+avx,+aes,+xsave,+xsaveopt,check"
ALLOCATED_RAM="12288" # MiB
CPU_SOCKETS="1"
CPU_CORES="2"
CPU_THREADS="4"
REPO_PATH="."
OVMF_DIR="."
args=(
-enable-kvm -m "$ALLOCATED_RAM"
# Set the CPU model and options
# Use Haswell-noTSX for Sonoma and Penryn for older versions
-cpu Haswell-noTSX,kvm=on,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,"$MY_OPTIONS"
-machine q35
-device qemu-xhci,id=xhci
-device usb-kbd,bus=xhci.0 -device usb-tablet,bus=xhci.0
-smp "$CPU_THREADS",cores="$CPU_CORES",sockets="$CPU_SOCKETS"
-device usb-ehci,id=ehci
-device isa-applesmc,osk="ourhardworkbythesewordsguardedpleasedontsteal(c)AppleComputerInc"
-drive if=pflash,format=raw,readonly=on,file="$REPO_PATH/$OVMF_DIR/OVMF_CODE.fd"
-drive if=pflash,format=raw,file="$REPO_PATH/$OVMF_DIR/OVMF_VARS-1920x1080.fd"
-smbios type=2
-device ich9-intel-hda -device hda-duplex
-device ich9-ahci,id=sata
# Add the OpenCore bootloader drive with boot priority
-drive id=OpenCoreBoot,if=none,snapshot=on,format=qcow2,file="$REPO_PATH/OpenCore/OpenCore.qcow2"
-device ide-hd,bus=sata.2,drive=OpenCoreBoot,bootindex=1
# Add the macOS hard drive
-drive id=MacHDD,if=none,file="$REPO_PATH/mac_hdd_ng.img",format=qcow2
-device ide-hd,bus=sata.4,drive=MacHDD
# Configure network with port forwarding for SSH access
-netdev user,id=net0,hostfwd=tcp::2222-:22
-device virtio-net-pci,netdev=net0,id=net0,mac=52:54:00:c9:18:27
# Disable the QEMU monitor interface and graphical output
-monitor none
-nographic
)
# Start the QEMU virtual machine in the background and disown the process
qemu-system-x86_64 "${args[@]}" > /dev/null 2>&1 & disown

View File

@ -13,7 +13,7 @@
# NOTE: Tweak the "MY_OPTIONS" line in case you are having booting problems! # NOTE: Tweak the "MY_OPTIONS" line in case you are having booting problems!
############################################################################### ###############################################################################
# #
# Change `Penryn` to `Haswell-noTSX` in OpenCore-Boot.sh file for macOS Sonoma! # Change `Haswell-noTSX` to `Penryn` in OpenCore-Boot.sh file for macOS Ventura and older versions!
# #
############################################################################### ###############################################################################
@ -23,7 +23,7 @@ MY_OPTIONS="+ssse3,+sse4.2,+popcnt,+avx,+aes,+xsave,+xsaveopt,check"
# This script works for Big Sur, Catalina, Mojave, and High Sierra. Tested with # This script works for Big Sur, Catalina, Mojave, and High Sierra. Tested with
# macOS 10.15.6, macOS 10.14.6, and macOS 10.13.6. # macOS 10.15.6, macOS 10.14.6, and macOS 10.13.6.
ALLOCATED_RAM="4096" # MiB ALLOCATED_RAM="12288" # MiB
CPU_SOCKETS="1" CPU_SOCKETS="1"
CPU_CORES="2" CPU_CORES="2"
CPU_THREADS="4" CPU_THREADS="4"
@ -33,7 +33,12 @@ OVMF_DIR="."
# shellcheck disable=SC2054 # shellcheck disable=SC2054
args=( args=(
-enable-kvm -m "$ALLOCATED_RAM" -cpu Penryn,kvm=on,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,"$MY_OPTIONS" -enable-kvm -m "$ALLOCATED_RAM"
# Set the CPU model and options
# Use Haswell-noTSX for Sonoma and Penryn for older versions
-cpu Haswell-noTSX,kvm=on,vendor=GenuineIntel,+invtsc,vmware-cpuid-freq=on,"$MY_OPTIONS"
-machine q35 -machine q35
-device qemu-xhci,id=xhci -device qemu-xhci,id=xhci
-device usb-kbd,bus=xhci.0 -device usb-tablet,bus=xhci.0 -device usb-kbd,bus=xhci.0 -device usb-tablet,bus=xhci.0
@ -53,9 +58,12 @@ args=(
-device ich9-intel-hda -device hda-duplex -device ich9-intel-hda -device hda-duplex
-device ich9-ahci,id=sata -device ich9-ahci,id=sata
-drive id=OpenCoreBoot,if=none,snapshot=on,format=qcow2,file="$REPO_PATH/OpenCore/OpenCore.qcow2" -drive id=OpenCoreBoot,if=none,snapshot=on,format=qcow2,file="$REPO_PATH/OpenCore/OpenCore.qcow2"
-device ide-hd,bus=sata.2,drive=OpenCoreBoot -device ide-hd,bus=sata.2,drive=OpenCoreBoot,bootindex=1
# **IMPORTANT:** Make sure to comment out the following two lines after macOS installation
-device ide-hd,bus=sata.3,drive=InstallMedia -device ide-hd,bus=sata.3,drive=InstallMedia
-drive id=InstallMedia,if=none,file="$REPO_PATH/BaseSystem.img",format=raw -drive id=InstallMedia,if=none,file="$REPO_PATH/BaseSystem.img",format=raw
-drive id=MacHDD,if=none,file="$REPO_PATH/mac_hdd_ng.img",format=qcow2 -drive id=MacHDD,if=none,file="$REPO_PATH/mac_hdd_ng.img",format=qcow2
-device ide-hd,bus=sata.4,drive=MacHDD -device ide-hd,bus=sata.4,drive=MacHDD
# -netdev tap,id=net0,ifname=tap0,script=no,downscript=no -device virtio-net-pci,netdev=net0,id=net0,mac=52:54:00:c9:18:27 # -netdev tap,id=net0,ifname=tap0,script=no,downscript=no -device virtio-net-pci,netdev=net0,id=net0,mac=52:54:00:c9:18:27

1940
OpenCore/Boot-NoUI/config.plist Executable file

File diff suppressed because it is too large Load Diff

106
README-NoUI.md Normal file
View File

@ -0,0 +1,106 @@
## Setup Instructions - SSH iOS Development Environment
### Step 1: Clone the Repository
Clone this repository to your local machine and navigate to the repository root.
### Step 2: Follow Initial Setup Instructions
Follow the steps in the [README.md](README.md) file to set up the environment and install macOS (Sonoma).
### Step 3: Initial VM Boot
Start the VM for the first time with the GUI to complete the initial macOS setup:
```bash
./OpenCore-Boot.sh
```
Complete the macOS setup and install XCode and other GUI-dependent tools.
**Note:** Active SSH on macOS `System Preferences > Sharing > Remote Login`.
### Step 4: Install XCode and Generate Unique Serial
If you need to install XCode, you'll need a unique serial number. Complete steps 1-5 below and start `./OpenCore-Boot.sh` again to connect to your Apple account, install XCode, and other tools.
1. Navigate or clone GenSMBIOS repository into workspace:
```bash
git clone https://github.com/corpnewt/GenSMBIOS.git
cd GenSMBIOS
```
2. Make `GenSMBIOS.command` executable and run it:
```bash
chmod +x GenSMBIOS.command
./GenSMBIOS.command
```
3. Install/Update MacSerial.
4. Select `$osx_kvm_path/OpenCore/Boot-NoUI/config.plist` as the configuration file.
5. Generate SMBIOS for `iMacPro1,1`.
6. Generate UUID.
### Step 5: Generate OpenCore Image with NoUI Configuration
```bash
# Update submodule
git submodule update --init --recursive ./resources/OcBinaryData
cd ./OpenCore
# Generate OpenCore image with NoUI configuration
rm -f OpenCore.qcow2; sudo ./opencore-image-ng.sh --cfg ./Boot-NoUI/config.plist --img OpenCore.qcow2
```
### Step 6: Start OpenCore VM with NoUI Configuration
```bash
# Navigate to repository root
cd $osx_kvm_path
# cd ..
# Make the shell script executable
chmod +x ./OpenCore-Boot-NoUI.sh
./OpenCore-Boot-NoUI.sh
```
### Step 7: Connect to macOS VM with SSH
```bash
ssh -p 2222 $user_name@localhost
```
### Step 8: Map Port 22 to 2222 and Open Firewall
```bash
# Map port 22 to 2222
sudo iptables -t nat -A PREROUTING -p tcp --dport 22 -j REDIRECT --to-port 2222
# Open firewall
sudo iptables -A INPUT -p tcp --dport 22 -j ACCEPT
```
### Step 9: Connect from Any Device on the Network to the VM
```bash
ssh $user_name@$vm_host_ip
```
### Step 10: Shutdown the VM
```bash
# (run on mac via SSH)
sudo shutdown -h now
```
## Additional Notes
I personally use Nix flakes to manage the environment, so I can install all the required tools with `nix develop` and run the scripts from there. (The Nix package manager does not support XCode, so you need to install it manually first.)
Additionally, I use GitHub to store my credentials, which allows me to just copy the `.gitconfig` and `.git-credentials` to the user home directory on the VM.
To debug iOS apps, it's easiest to use XCode Wi-Fi debugging, so you don't need to connect the phone to the VM.

View File

@ -529,8 +529,8 @@ def main():
{"name": "Catalina (10.15)", "b": "Mac-00BE6ED71E35EB86", "m": "00000000000000000", "short": "catalina"}, {"name": "Catalina (10.15)", "b": "Mac-00BE6ED71E35EB86", "m": "00000000000000000", "short": "catalina"},
{"name": "Big Sur (11.7)", "b": "Mac-2BD1B31983FE1663", "m": "00000000000000000", "short": "big-sur"}, {"name": "Big Sur (11.7)", "b": "Mac-2BD1B31983FE1663", "m": "00000000000000000", "short": "big-sur"},
{"name": "Monterey (12.6)", "b": "Mac-B809C3757DA9BB8D", "m": "00000000000000000", "os_type": "latest", "short": "monterey"}, {"name": "Monterey (12.6)", "b": "Mac-B809C3757DA9BB8D", "m": "00000000000000000", "os_type": "latest", "short": "monterey"},
{"name": "Ventura (13) - RECOMMENDED", "b": "Mac-4B682C642B45593E", "m": "00000000000000000", "os_type": "latest", "short": "ventura"}, {"name": "Ventura (13)", "b": "Mac-4B682C642B45593E", "m": "00000000000000000", "os_type": "latest", "short": "ventura"},
{"name": "Sonoma (14) ", "b": "Mac-A61BADE1FDAD7B05", "m": "00000000000000000", "short": "sonoma"} {"name": "Sonoma (14) - RECOMMENDED", "b": "Mac-A61BADE1FDAD7B05", "m": "00000000000000000", "short": "sonoma"}
] ]
for index, product in enumerate(products): for index, product in enumerate(products):
name = product["name"] name = product["name"]