4-Way Fat Binaries, 10.4 through 10.5
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:
- Use the 10.5 SDK
- Set the deployment target to 10.5
- …except for ppc
- … 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.
You should not target ppc64. It has several subtle bugs and problems and in generally is not nearly as well supported and tested as the other 3 architectures. Stick to ppc, i386 and x86_64.