Building universal binaries that will run in all OS X versions

One drawback of universal binaries is that they require GCC 4.0, which produces applications that won’t run in 10.2. For a truly universal binary you need to use an older version of GCC for the PPC code. The latest version of XCode allows you to specify separate settings for x86 & PPC code, although it isn’t really obvious how to do it. After some digging I figured it out.

Some of the build settings such as SDKROOT & GCC_VERSION allow you to specify which architecture they apply to by appending _ppc or _i386 to the settings name. Here’s how I’m able to build a universal binary that will run on OS X 10.2 or later (which requires it to be built with GCC 3.3) as well as x86.

First, set up the project & target settings as required for building the x86 version. Then add the following variables to the build panel of the project or target settings window (hit the ‘+’ button to add a variable & edit the name).

MACOSX_DEPLOYMENT_TARGET_ppc  10.2
GCC_VERSION_ppc               3.3
SDKROOT_ppc                   /Developer/SDKs/MacOSX10.2.8.sdk

Those settings will override the defaults when building a PPC binary, while the defaults will be used when building x86.

Tags:

One Response to “Building universal binaries that will run in all OS X versions”

  1. macintron Says:



    I just arrived home from the “Universal Binary Workshop” organized from Apple. Thats the way Apple suggests it:

    Debug:

    SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk
    MACOSX_DEPLOYMENT_TARGET = 10.4
    GCC_VERSION_ppc = 3.3
    MACOSX_DEPLOYMENT_TARGET_ppc = 10.2
    OTHER_LD_FLAGS_ppc = /Developer/SDKs/MacOSX10.2.8.sdk/usr/lib/gcc/darwin/3.3/libstdc++.a
    SDKROOT_ppc = /Developer/SDKs/MacOSX10.2.8.sdk
    

    Release:

    ARCHS = ppc i386
    SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk
    GCC_VERSION_ppc = 3.3
    MACOSX_DEPLOYMENT_TARGET_ppc = 10.2
    OTHER_LD_FLAGS_ppc = /Developer/SDKs/MacOSX10.2.8.sdk/usr/lib/gcc/darwin/3.3/libstdc++.a
    SDKROOT_ppc = /Developer/SDKs/MacOSX10.2.8.sdk
    


Leave a Reply

You must be logged in to post a comment.

MacMegasite is Digg proof thanks to caching by WP Super Cache!