Develop iOS apps on your Windows PC for free
Unfortunately to develop iOS apps, whether natively using Swift or by using frameworks like Flutter and Kotlin Multiplatform, you’ll need an up-to-date macOS to run the latest Xcode IDE and compile your code. But what if you can’t let go of your beloved PC and migrate to Apple’s restricted ecosystem to do so? Here we’ll go through the process of setting up macOS Ventura inside Windows 10/11 so we can benefit from Xcode on our PC.
Optimize Linux Windows Subsystem
Step 1.1: Start Terminal with administrative privileges.
Step 1.2: Execute wsl --update
command and wait for the update to finish.
Step 1.3: Open %userprofile%
directory on your Windows.
Step 1.4: Create a file and name it .wslconfig
.
Step 1.5: Paste the following code in the file and save:
[wsl2]
# Limit VM memory to use no more than allocated amount, this can be set as whole numbers using GB or MB
memory=8GB
[experimental]
# Automatically release cached memory after detecting idle CPU usage.
autoMemoryReclaim=gradual
# Automatic disk space clean up (Set sparse VHD)
sparseVhd=true
IMPORTANT: In the configuration above, change the allocated system memory to your desired amount. Preferably half your total system memory.
Install Linux on Windows with WSL
Step 2.1: Execute wsl --install
command to start Ubuntu installation.
Step 2.2: Enter a username and password of your choice when asked.
Step 2.3: Execute sudo apt update && sudo apt upgrade
to update Ubuntu and its packages to the latest versions. Enter your password when asked and accept the installation of new packages by pressing Y and then Enter.
Now that Linux Ubuntu is installed on your Windows, you can proceed to execute bash commands and install Linux software. To do so, you can reopen Terminal to see the newly added Ubuntu command line.
Prepare macOS Ventura installation
Step 3.1: Install QEMU emulator and other required packages.
sudo apt-get install qemu uml-utilities virt-manager git \
wget libguestfs-tools p7zip-full make dmg2img tesseract-ocr \
tesseract-ocr-eng genisoimage -y
Step 3.2: Clone OSX-KVM repository.
git clone --depth 1 --recursive https://github.com/kholia/OSX-KVM.git
Step 3.3: Navigate to the cloned repository.
cd OSX-KVM
Step 3.4: Pull the latest repository updates.
git pull --rebase
Step 3.5: Fetch macOS installer.
./fetch-macOS-v2.py
Step 3.6: Type 6 to select Ventura and press Enter. Wait for the download to finish.
Step 3.7: Convert the installer to IMG format.
dmg2img -i BaseSystem.dmg BaseSystem.img
Step 3.8: Create a virtual hard drive where macOS will be installed. A minimum size of 80GB is recommended.
qemu-img create -f qcow2 mac_hdd_ng.img 80G
Step 3.9: By default, only 4GB of ram and 2 CPU cores are allocated to your macOS. To allocate more resources, execute nano ./OpenCore-Boot.sh
to open the editor. Look for the lines that specify ALLOCATED_RAM, CPU_SOCKETS, CPU_CORES and CPU_THREADS. I recommend allocating 0.5GB less memory than your provided to WSL. As for the CPU cores, choose the numbers that suit you best. In the end, save the changes and quit the editor.
Install macOS Ventura
Step 4.1: Execute sudo ./OpenCore-Boot.sh
to start the installation process.
Step 4.2: From the opened window, select macOS Base System.
Step 4.3: Use the Disk Utility tool within the macOS installer to partition, and format the virtual disk attached to the macOS VM.
Step 4.4: Close Disk Utility and go ahead with Reinstall macOS Ventura.
Install Xcode
Welcome to macOS! How does it feel? Let’s continue with installing Xcode and start coding, shall we?
Step 5.1: Open App Store, search for Xcode and click on the Get button to install it.
NOTE: The simplest way to import your existing projects to Xcode is to upload it to your cloud storage (e.g. Google Drive or Proton Drive) and download it again inside your macOS.
Verdict
As you can see, although the process is breathtaking, developing iOS apps on PC is absolutely possible. The biggest issue to be aware of though, is Apple moving away from x86 architecture, meaning future macOS releases will most likely drop support for Intel CPUs, which were shipped on older Mac notebooks. This is bad news because you can install the latest Xcode only on the latest macOS. To be clear, macOS Sonoma is already out for several months and it has boatload of issues while in emulation, practically making it impossible to work with. But until then, happy coding!