Wednesday, July 7, 2010

Populating iPhone Simulators With Photos

If you develop apps, most probably you will want a user to load up his/her own photo into the app. You can test the UIImagePickerController function by testing loading a photo from either the "Saved Photos" folder or "Photo Library" folder inside the Photos App. But often, after a new installation, both folders are empty.

To save the photos to Saved Photos album, you can just drag any images onto the iPhone simulator whereby it will opened automatically with Safari. Then you can click and hold on the image and an ActionSheet will slide up and you can save it. Images saved in this way are copied to the Saved Photos album. How about Photos Library folder? See below:

There are 2 ways:

1. To populate the folder Saved Photos: Copy and paste photos to this folder (if not exist, create it by yourself):

[USER]/Library/Application Support/iPhone Simulator/User/Media/DCIM/100Apple/...

2. To populate the folder Photo Library (if not exist, create it by yourself):

[USER]/Library/Application Support/iPhone Simulator/User/Media/Photos/...

Developers On MacBook Beware.

This post is not really a coding tutorial. Instead I will be sharing on how things get pretty gooey if you use a Macbook to develop iPhone apps on. You probably can guess what is the problem, yep, the DVD drive gave away its life too soon.

iPhone SDK 4 is out and Apple makes it a requirement to produce apps/updates compiled with SDK 4. It requires Snow Leopard, but my Macbook was running Leopard still! So I went to an Apple Premium Reseller and bought the Snow Leopard installer DVD. Excited, rushed home and slipped the disc inside the Macbook and it spinned for a while and spit it back out. It kept doing that forever. So it is positive, the drive is malfunctioning.

So I thought.. Great.. what now?

After hours of searching, I finally came across an answer via google - to make a clone of the DVD into a Thumbdrive! Yep. But how to do that if the Macbook DVD drive cannot read the Installer DVD? You are out of luck really. Except if you have another computer, which I have -  another desktop PC running Windows XP. Now if you have another Mac with good disc drive, it would be easy to just fire up the Airport and install remotely. But if you just have a PC, it is going to be a little bit difficult.

Now, if you put the Installer DVD into a Windows PC, the boot sector of that disc is going to hide everything else, except the Windows related programs - which are utility to Remote Install. You can do this if you have a WiFi (ie Airport). My PC only have a bluetooth, so that option is out of the window.
I also do not have a Firewire cable, which is another option to use to do Remote Install.

So, what I did was googled a Free Iso Creator software, downloaded it and generate a disc image of the Installer DVD on my PC's hard disk. The name has *.iso extension on it. rename that to *.dmg (which will be recognized by Mac OS). The size is 7.45GB. For some reason, my so called 8GB Sandisk Cruzer USB drive was a rip off. It is not really 8GB, it is 8million bytes, which is 7.40GB. So, I cannot copy this 7.45GB image file onto my USB. Crap!

Then WinRAR springs to mind. Downloaded the trial version and start to archiving the 7.45GB file into 5 pcs of ~ 1.3GB files. Then transfer them bit by bit to my Mac. Once all the 5 pieces of 1.3GB files are in my Macbook, I need to stitch them up back together.. so I downloaded UnRarX (a cool free extractor for Mac) and start combining back those files into 1 big 7.45GB installer image file.

Next, what I did was open up Disk Utility in my Macbook, plug in my "8GB" thumbdrive and do a Restore using the image file that was retrieved earlier. Remember to format the thumbdrive and partition it as GUID Apple format, which will make it bootable.

Once done, Mac OS immediately recognizes it and mount a virtual drive. Double click it and you will see the installer icon and voila! I could finally install Snow Leopard and SDK 4 on my Mac.

Hope this post would help someone in similar situation as mine. Wasted a whole 2 days just to do this. But glad that I found a way. I really don't want to spend hundreds of dollars to swap the drive or to buy external drive. Pheww...