Install XCode on Arch Linux

How To Install macOS Virtual Machine on Linux/Arch/Manjaro – Catalina, Mojave, or High Sierra! XCode working!

Linux users on Arch or Manjaro attempting to install macOS/OSX in VMWARE, or QEMU/KVM, will greatly benefit from this tutorial.

This tutorial is great for Linux users who want to use XCode 10 or 11 on Linux without Dual Booting!

How to Install macOS VM on Linux

Linux System Requirements:

  • an aur package manager, such as yay.
  • about 20-40gb of free space
  • Intel VT-x / AMD SVM: in your BIOS turn on “hardware virtualization” or similar

Suggestions:

  • highly recommend using an SSD
  • where you download and run the scripts will determine which drive the OSX image will be created on

If you don’t have yay (Arch User Repository package manager):

git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si

Next, we will need git & python as we will need to clone some repositories.

sudo pacman -R git python

You will need a MAC iso file, which is around 6GB downloaded.
Make sure you download the iso in the disk or device that you are going to run the VM from.
A great way to download OSX ISO files is using gibMacOS:

git clone https://github.com/corpnewt/gibMacOS.git
cd gibMacOS
./gibMacOS.command

This will run a small Python script that will allow you to download mac iso files from *.apple.com

The version that worked for me was Mojave 10.14.6

macOS Mojave 10.14.6 (18G103)

gibmacos Choose macOS ISO for Downloading on Linux
gibmacos Choose macOS ISO for Downloading on Linux

Next, you will need qemu & libvirt for virtualisation and emulation.
Also required during qemu installation:
dnsmasq for networking
virt-manager but not required
bridge-utils for additional networking Requirements

sudo pacman -S qemu libvirt dnsmasq virt-manager bridge-utils

Now, enable libvirt and virtlogd

  • libvirt is libraries required for virtualisation
  • virtlogd is logging of the qemu virtual instances
sudo systemctl enable libvirtd.service
sudo systemctl enable virtlogd.service

Additionally, you will require the following packages which are found only in the Arch User Repository.

Most of them are on Github if you want to compile them yourselves.
Installing these will take some time, so one-by-one install these:

yay uml-utilities
yay libguestfs
yay ebtables
yay firewalld
yay virsh
sudo firewalld

If you are on Debian or Ubuntu

1
sudo apt-get install qemu uml-utilities virt-manager dmg2img git wget libguestfs-tools

The following program qt-virt-manager is huge and takes a long time to compile but you might need it:

# yay qt-virt-manager

You should reboot now to apply kernel changes for qemu.

Next, download the OSX-KVM Repository:
This folder will be referred to as the OSX-KVM folder.

Your macOS disk will be created in the folder we are about to download.

Make sure you choose a disk with enough space.

git clone https://github.com/kholia/OSX-KVM.git
cd OSX-KVM
# if you didnt use gibMacOS to download the OSX ISO you can use: 
# ./fetch-macOS.py

Converting macOS BaseSystem.dmg into Disk Image

In the gibMacOS folder that you downloaded earlier, navigate into:
macOS Downloads > publicrelease, and then the folder of the OSX Version that you downloaded.

Inside the macOS version folder that you downloaded from gibMacOS, we will turn the .dmg into .img
Make sure you have enough disk space here!

Find BaseSystem.dmg inside the gibMacOS downloaded folder. It should be around 500mb.
Convert it to .img:

# do this inside gibMacOS/macOS Downloads/publicrelease/061-26589 - 10.14.6 macOS Mojave/

qemu-img convert BaseSystem.dmg -O raw BaseSystem.img

Now move the BaseSystem.img that you just created FROM the gibMacOS folder -> TO THE OSX-KVM FOLDER

Move BaseSystem to OSX-KVM Folder
Move BaseSystem to OSX-KVM Folder

Decide now how big you want the macOS disk size to be.

I want an 80GB macOS disk size so I run the command below.
Note: do not change “mac_hdd_ng.img” or it will break the scripts later.

qemu-img create -f qcow2 mac_hdd_ng.img 80G

The 80GB empty disk has been created.
The macOS image is ready.

Now, create the network for the OSX VM

If you have successfully installed all the AUR packages above, you should be able to run this:

Run these commands one-by-one:

sudo ip tuntap add dev tap0 mode tap
sudo ip link set tap0 up promisc on
sudo virsh net-start default
sudo virsh net-autostart default
sudo ip link set dev virbr0 up
sudo ip link set dev tap0 master virbr0
macOS VMWARE Virtual Networking
macOS VMWARE Virtual Networking

Mac is now ready to boot.

Inside the OSX-KVM folder, run the shell script run-diagnostics.sh

./run-diagnostics.sh

If everything looks okay, you are ready to boot macOS on Arch Linux.

macOS Run Diagnostics
macOS Run Diagnostics

Boot macOS

./boot-macOS-NG.sh

Boot and Installation Process

Hint: in QEMU, press Ctrl + Alt + G to gain control of your mouse again.

At the CLOVER Boot Manager screen, select:
Boot macOS Install from macOS Base System

macOS Clover Boot Linux AMD OSX
macOS Clover Boot Linux AMD OSX

After about a minute, the macOS recovery GUI will appear and you can select your language.

When you reach the macOS Utilities screen, seleck “Disk Utility”

macOS on Linux Disk Utility
macOS on Linux Disk Utility

In the top left, select “Show All Devices”. Not required to see the disk we are using, but helpful to visualize what is happening

Show All Devices OSX Disk Utility
Show All Devices OSX Disk Utility

Select the disk which has 80GB and is “Uninitialized”.

Uninitialized QEMU Disk for macOS on Linux
Uninitialized QEMU Disk for macOS on Linux

Click on “Erase” and erase the 90GB disk.

Do not change the Format or Scheme.

Erasing the disk here does nothing to your real computer. This is a virtual drive.

Erase Disk macOS Linux
Erase Disk macOS Linux

Create a new partition for macOS on your QEMU Drive

NOTE: YOU MUST REDUCE THE DISK SIZE BY A SMALL AMOUNT TO BE ABLE TO PRESS APPLY

After you have erased the disk, click “Partition”.

Partitioning QEMU Drive on Linux for macOS
Partitioning QEMU Drive on Linux for macOS
Change 85.6 to 85.5 and you will be able to press apply.
You Must Reduce the Partition Size by any amount
You Must Reduce the Partition Size by any amount.

Note: this will NOT steal 80GB straight away from your hard drive:  it’s just virtually allocating it from your host machine’s disk.

Create macOS partition for Arch Linux QEMU
Create macOS partition for Arch Linux QEMU

When that has finished, you can close the “Disk Utility”

Select Reinstall macOS.

Reinstall macOS on QEMU
Reinstall macOS on QEMU
Install macOS Mojave on Arch Linux
Install macOS Mojave on Arch Linux

Have fun using macOS on Linux with QEMU!

Install XCode on Arch Linux
Install XCode on Arch Linux

Leave a Reply

Your email address will not be published. Required fields are marked *