I, Patrick McCarron, am an iOS and Mac app / game developer from Chicago. I developed one of the first iPhone games back in 2007 and haven't stopped since. Check out my app Portfolio for more info on the projects I've worked on.

I'm also an avid video game enthusiast who has been writing FAQs, websites and guides for video games since the 90s. I currently run the longest running Mortal Kombat fan site: The Realm of Mortal Kombat (TRMK) in my spare time.

Xbox Live: McCarron
PlayStation Network: McCarron X
Game Center: McCarron
Follow Patrick McCarron on Twitter View Patrick McCarron's LinkedIn profile View Patrick McCarron's Flickr Photo Album View Patrick McCarron's Facebook profile

My Portfolio

Ask me a question

Archive

RSS

Patrick McCarron's
Infinite Shamrock

 

June 16
2009

iPhone 2.x SDKs on Snow Leopard

Thanks to quatermain for finding the best way to compile against the 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:

  1. 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.
  2. 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.
  3. On Leopard (and for the iPhone, which is based on Leopard) this looked in usr/gcc/i686-apple-darwin9/include.
  4. On Snow Leopard, the current system is Darwin version 10, so it will look in usr/gcc/i686-apple-darwin10/include. Hence the symlink.
  5. 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 /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.1.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.