iPhone 2.x SDKs on Snow Leopard
So, it’s been reported extensively on Twitter that the iPhone SDK package for Snow Leopard only includes SDKs for OS 3.0. This causes some problems because the SDK you build with inserts a key into your Info.plist which tells the device/store what SDK you’re targetting. This isn’t modified by the ‘iPhone OS Deployment Target’ build setting, and causes the Store to limit which devices you can install the app on, and causes the device to use 3.0-specific behaviours. This means that you WILL need to tweak coordinates and offsets to match the differences for OS 3.0, while apps build with, say, the 2.0 SDK will cause the device to emulate the behaviour of UIKit on 2.0.
There have been a few attempts to define how to make it work, but ultimately these may only work for Device SDKs, not Simulator ones. And even so, these still fall afoul of the ‘DTSDKName=iphoneos3.0’ setting created by the target SDK, so you still won’t get 2.x behaviour or be able to install on 2.x devices via the App Store.
So, after a LOT of fiddling, I have discovered the following:
- In the Snow Leopard OS 3.0 SDKs, you have the path usr/gcc/i686-apple-darwin10, which is symlinked to usr/gcc/i686-apple-darwin9.
- When building things which use <stdarg.h> and similar compiler-dependent things, the system will look inside gcc/[arch]-[vendor]-[osversion]/include for the compiler-dependent versions of those headers.
- On Leopard (and for the iPhone, which is based on Leopard) this looked in usr/gcc/i686-apple-darwin9/include.
- On Snow Leopard, the current system is Darwin version 10, so it will look in usr/gcc/i686-apple-darwin10/include. Hence the symlink.
- Therefore to get the older SDKs building properly (by getting access to those compiler-specific headers) you need to create the darwin10 symlink.
To do this, you basically do the following commands:
> cd [PATH_TO_SDK]/usr/lib/gcc> sudo ln -s i686-apple-darwin9 i686-apple-darwin10
Now, unless you manually set a specific compiler in your build settings, the default when using the 2.x iPhone SDKs will be gcc 4.0.1, which works fine now. If you want to use gcc 4.2.1, you’ll need to copy [OS3SDK]/usr/lib/i686-apple-darwin9/4.2.1 and [OS3SDK]/usr/lib/gcc/i686-apple-darwin9/4.2.1 into the same places in your 2.x SDKs.
If that sounds a little fiddly, then hang in there. I’ll be distributing an app to do all that for you in a little while.