Distributing a single screen saver for 10.4, 10.5 and 10.6

In an earlier post, I discussed some Xcode settings that would simplify creating a Universal Binary screensaver that would run on all three versions of Mac OS X. Since that post, I’ve run into some problems and had some feedback, and discovered additional possible problems and solutions.

First off, there are a confusing number of settings related to architecture and SDK selection:

    Settings in the pop-up in the upper-left of the Xcode window:

  • Active SDK – affects the -isysroot argument to gcc
  • Active Architecture – affects the -arch argument to gcc
  • *above ONLY if the “Build Active Architecture Only” box is Unchecked in the Project Info
  • Settings in the Project Info, under the Build tab

  • Base SDK (SDKROOT variable)
  • Mac OS X Deployment Target (MACOSX_DEPLOYMENT_TARGET)

Further, within your code, you may reference the following two macros:

  • MAC_OS_X_VERSION_MIN_REQUIRED
  • MAC_OS_X_VERSION_MAX_ALLOWED

Through reading Apple’s documentation and a process of trial and error, I have come to the following conclusions:

  • MAC_OS_X_VERSION_MIN_REQUIRED is based on MACOSX_DEPLOYMENT_TARGET, and is the minimum version of OS X which you can expect your code to run on. This is generally based on the Base SDK setting above.
  • MAC_OS_X_VERSION_MAX_ALLOWED is the latest version of the Mac OS X API that you code uses native APIs from. This is generally based on the Mac OS X Deployment Target setting above, unless the Active SDK setting is less than the Mac OS X Deployment Target.
  • Because of the above side-effect, it seems the best practice is to leave the Active SDK setting to the latest version of the Mac OS X SDK your program will run on, regardless of architecture.
  • APIs between MAC_OS_X_VERSION_MIN_REQUIRED and MAC_OS_X_VERSION_MAX_ALLOWED will be weak linked.
  • For more complete documentation, read up on Apple’s Technote TN2064

Here’s an example of the settings that I now use: