PhoneGap iOS installer bug (and workaround)

I was trying to install PhoneGap iOS on my new MacBook Air but got an error when I ran the PhoneGapLibInstaller.pkg installer. It was telling me that I didn't have Xcode installed when, in fact, I did. I just didn't have it installed in the default location (/Developer).

(Since I usually have several versions of Xcode on my machine at the same time, I've taken to installing them off the root in descriptive folders – e.g., Xcode3.2.4iOS4.1, etc.)

A cursory glance through the installer code revealed that the installer doesn't appear to need to do anything with Xcode, it just checks whether it exists (at the default location). Specifically, it checks if Xcode is installed by checking for the existence of /Developer/Applications/ and if the iOS SDK is installed by checking for /Developer/Platforms/iPhoneOS.platform. So, as a workaround, I rebuilt the packager from source and removed the two requirements. Lo and behold, the installer ran beautifully.

It's a niche issue (most people have Xcode installed in the default location), and I know that the PhoneGap team are aware of it, Dave Johnson was looking into it, and Shazron Abdullah just posted a gist on the issue, so I'm sure that a fix will be out shortly.

In the meanwhile, if you're affected by the issue, you can grab my installer (.zip; 356KB), which doesn't have the two checks in it, and try using that instead.