Are you tired of juggling multiple devices for Xamarin development? Do you wish you could harness the power of OS X without being tied to an Apple ecosystem? Look no further! In this comprehensive guide, we'll walk you through the process of setting up a virtual machine running macOS X Sierra on your Windows PC using VirtualBox.
Requirements
Before we dive in, make sure you have the following:
- A macOS X Sierra installer or a machine with Sierra installed
- An Intel-powered machine, preferably an i5 or higher
- A 16GB or larger thumb drive, preferably USB 3.0 or higher
- VirtualBox 5.x
- Visual Studio 2015 or higher (for Xamarin development)
- A laptop with a power source (if applicable)
Create the OS X Installer USB Drive
To get started, you'll need to create an installer for your Sierra virtual machine. This involves formatting a thumb drive and extracting the Sierra installer.
- Insert the thumb drive into your Mac or PC and launch Disk Utility.
- Format the USB drive with the name "USB" and the format of GUID Partition Map.
- Download the macOS Sierra installer via the App Store and save it to your Applications folder.
- Make a copy of the installer for safekeeping, then run Unibeast and follow the prompts.
- Choose Legacy boot mode and let Unibeast create the thumb drive (approximately 10 minutes on a USB 3 drive).
- Download Multibeast and copy it to the newly created Unibeast drive.
Create the VirtualBox USB Drive Shim
VirtualBox doesn't natively support booting from a USB drive, so we'll need to create a virtual disk that points to our thumb drive.
- Open Disk Management and get the Disk Number of the thumb drive.
- Open Command Prompt as an administrator and navigate to
%programfiles%\oracle\virtualbox. - Run the command
VBoxManage internalcommands createrawvmdk -filename C:\usb.vmdk -rawdisk \\.\PhysicalDrive#to create the virtual drive pointer.
Create the VM
Now that we have our thumb drive and shim, it's time to set up our VirtualBox virtual machine.
- Right-click VirtualBox and select "Run as Administrator" to launch the application.
- Follow the instructions on this page to configure your VM, ignoring the download portion (you already have an install thumb drive).
- Create a new VM named "Sierra" (or whatever you prefer) and choose OS X 64-bit as the guest OS.
- Set the RAM to 4GB (you can adjust this later if needed).
Configure Your VM
Once your VM is set up, it's time to configure it for optimal performance.
- Add a virtual disk to stand in as your Mac's hard drive, using VDI format and dynamically sized at 60 GB.
- Confirm the settings match those below:
- System, Motherboard, Base Memory: 4096 MB
- System, Motherboard, Boot Order: Only Optical and Hard Disk checked
- System, Processor, Processors: 2 CPUs
Tips and Tricks
- Don't skimp on virtual disk size – XCode uses a lot of space when it updates.
- Save the VM's drive to a location with enough space if you're concerned about running out.
By following these steps, you'll be well on your way to streamlining your Swift app development workflow. Happy coding!