4-Way Fat Binaries, 10.4 through 10.5

June 2, 2009
Tags: ,

I’ve seen this question come up several times in the past week: “How do I build a single Cocoa application that runs on both 10.4 and 10.5, and runs 64-bit where possible.”

Easy. Copy and paste the following settings into your project or target settings as appropriate:

SDKROOT = macosx10.5
MACOSX_DEPLOYMENT_TARGET = 10.5
MACOSX_DEPLOYMENT_TARGET[arch=ppc] = 10.4
MACOSX_DEPLOYMENT_TARGET[arch=i386] = 10.4

That’s all you need. In plain English, these build settings mean:

  1. Use the 10.5 SDK
  2. Set the deployment target to 10.5
  3. …except for ppc
  4. … and i386, both of which use a deployment target of 10.4

It’s that simple. The resulting application will run with the “best” architecture, everywhere. The one caveat is that, at least in the 32-bit case, you have to check at runtime if you happen to be using 10.5-only APIs. If you’re sure that you don’t need to use any 10.5-only functionality, and can stick to 10.4-only APIs, you can use the following build settings instead:


SDKROOT = macosx10.5
SDKROOT[arch=ppc] = macosx10.4
SDKROOT[arch=i386] = macosx10.4
MACOSX_DEPLOYMENT_TARGET = 10.5
MACOSX_DEPLOYMENT_TARGET[arch=ppc] = 10.4
MACOSX_DEPLOYMENT_TARGET[arch=i386] = 10.4

These settings mean the same as the previous snippet, except that the ppc and i386 slices use the 10.4 SDK.