2011年2月24日木曜日

iPhone SDK on Mac OS X 10.6.4 under VmWare

This guide shows you how to get the latest iPhone SDK running on Mac OS X 10.6.4 under VmWare.


Pre-requisites:

1. A computer whose CPU supports hardware virtualization. You can check if your computer supports this by using CPUZ and check if your CPU supports VT-X instructions.
2. At least 3GB of RAM on host with at least 2GB of RAM allocated to VMWare image.
3. OS X 10.6.4 VMWare disk image which can be downloaded here
4. The latest iPhone SDK downloaded from here
5. A Windows tool to create ISO file, such as MagicISO or WinISO
6. A file splitter tool for Windows such as FFSJ or HJSplit
7. A file joiner tool for Mac such as AJoiner

Steps:

1. Download and start the VMX virtual machine. 

The machine should boot up from the emulated CD-ROM, showing the modified Darwin bootloader. Wait at least 15 seconds before pressing F5 and select the Apple icon to boot into Mac OS X from the virtual hard disk.



If you select the icon too soon, for some reason, the bootloader will not see the hard disk and you will be stuck at the loading screen forever. If VmWare reports no disk activity a few seconds after the loading screen comes up, reset the machine and try again. Try to wait longer and press F5 a few times before selecting the Apple icon.



2. Configure Mac OS X

The default language of the downloaded OS X image will be Russian. To change to English, you'll need to open the Preferences tab by clicking the top-left Apple logo and trying the various menu options until you get a panel that looks like the following:

Click on the International icon (it should be in the first row). After that, select English and drag it to the top of the list. It should look like the following:
After that, switch to Formats and Input menu and change everything to English (optional)

Disable Software Updates, Sleep (under Energy Saver), Screen Saver and Time Machine.

Also, go to Date & Time preferences, disable time synchronization and select a timezone so that the Mac system time is the same as what is displayed by Windows. This is needed because OS X assumes system time to be in GMT.

3. Increasing the hard disk size to 40 GB

The default hard disk size is too small (20GB) for the iPhone SDK. However, expanding the hard disk is not as simple as using VmWare to expand it to 40 GB and run Disk Utility to grow the partition. If you try it, you will get the "mediaKit reports partition map too small" error message. GParted also won't help as it can only shrink, not grow HFS+ partition.

I even tried to use CloneZilla to backup the original HFS+ partition from the 20GB hard disk, and restore it to the new HFS+ partition on the 40GB hard disk. This time, although Disk Utility shows the HFS+ partition size correctly as 40GB, Finder still reports the size as 20GB. Attempting to repair the disk under Disk Utility fails with error "invalid b-tree node size". A Google search suggests DiskWarrior which unfortunately does not boot up under VmWare using the modified Darwin boot loader.

The solution (unbelievably simple) that I found was

a. Add a new virtual IDE (not SCSI) 40GB hard disk to the original OS X image.
b. Boot up from the original hard disk and use Disk Utility to create a single HFS+ partition on the 40GB hard disk.
c. Use Disk Utility to restore the original OSX partition to the newly created partition.
d. Shutdown OSX. Under the properties of the virtual machine, remove the newly created hard disk (not the image) and change the original hard disk to point to the new image.
e. Reboot. OSX should now see the hard disk as 40GB.

4. Getting the iPhone SDK installer on OSX

This is the tricky part. I have tried the following but failed:

a. Use Safari inside OS X to download the SDK. 
For some reason the download was successful but the resulting DMG file was corrupted.
b. Download it under Windows to an external hard disk drive and use the Vmware's VM menu to map the drive to OS X.
OS X would recognize the file and seemed to be able to copy it over. The copy process however would hang Finder prematurely and I had to resort to a reboot.
c. Same as (b) but splitted the file to smaller parts before copying.
OS X would still hang while copying, no matter how small the size of each segment is. This seems to be a problem with how VmWare manages the hardware.

The solution I found is

a. On Windows, split the DMG file to many segments around 100 MB each using HJSplit/FFSJ.
b. Use MagicISO/WinISO to create an ISO file with all the splitted segments
c. Use VmWare to add a new virtual CD-ROM drive to the OS X which points to the ISO file.
d. Open the emulated drive in OS X and copy the segments over.
e. Use AJoiner to merge all the segments to create the installer DMG file.

5. Installing the iPhone SDK

This step is straight forward and should take around 30 minutes to 1 hour, depending on the speed of your computer.

That's all. You can now enjoy iPhone development on your PC. In my computer, I allocate 4GB of RAM to OSX and it's really fast. Except that there's no sound support, the rest is just fine:




I hope this guide will help those who want to develop iPhone apps but do not have a Mac. If you encounter problems setting up the virtual machine, refer to this post.

0 件のコメント:

コメントを投稿