Supporting Older Versions of Mac OS X
A common question I see on Mac programming forums involves getting your program to run on older versions of Mac OS X. Suppose you’re writing a Mac application and you want it to run on Leopard (10.5) and Tiger (10.4). How do you get it to run on multiple versions of Mac OS X? Change the deployment target.
What’s the Deployment Target?
The deployment target is the earliest version of Mac OS X that can run your program. When you create an Xcode project, it sets the deployment target to the version of Mac OS X you’re using, which will be 10.5 if you’re using Xcode 3. The initial deployment target is fine if you’re writing programs for personal use, but your program won’t run if you give it to someone running an older version of Mac OS X. If you want your application to run on Leopard and Tiger, you must set the deployment target to 10.4.
In Xcode choose Project > Edit Project Settings to edit your project’s build settings. The Deployment Target build setting is in the Deployment build settings collection. If you set the deployment target to 10.4, your application will run on any Mac running Mac OS X 10.4 or higher. The previous sentence assumes your application is not using any technologies Apple introduced in Leopard, such as Core Animation.
What About the SDK?
When you installed Xcode, you installed one or more Mac OS SDKs (software development kit). The default installation of Xcode 3 installs the 10.4 and 10.5 SDKs. An SDK contains everything you need to build an application for a particular version of Mac OS X. The SDK for a particular version of Mac OS X contains the latest technologies your application can use. If you use the 10.5 SDK, your application can use Leopard technologies like toolbars created in Interface Builder and the new HID Manager APIs.
Xcode 3 projects initially use the 10.5 SDK. In most cases there is no need to change SDKs. The SDK has no effect on what versions of Mac OS X can run your program. You can use the 10.5 SDK and still support Tiger. Just set the deployment target to 10.4. By using the 10.5 SDK, your application can take advantage of any bug fixes Apple made in the 10.5 SDK. Normally the best course of action is to use the latest SDK while using the earliest deployment target you want to support.
When to Use an Earlier SDK?
Last section I said there was rarely a need to change SDKs. When would you want to use an earlier SDK? I can think of two reasons why you might want to use an earlier SDK. The first reason is if you want to build a version of your application for a specific version of Mac OS X. Suppose you had two versions of your application: one for Leopard and one for Tiger. You might want to use the 10.5 SDK for the Leopard version and the 10.4 SDK for the Tiger version.
The second reason is for testing purposes. Suppose you’re supporting Leopard and Tiger and you want to make sure you didn’t use any Leopard-specific function calls. You would temporarily use the 10.4 SDK so you could discover any compatibility errors when you build the project . Once your code compiled without any problems with the 10.4 SDK, you could switch to the 10.5 SDK. The Base SDK build setting lets you temporarily change the SDK. You could use the 10.4 SDK for the Debug build configuration and the 10.5 SDK for the Release build configuration.
Conclusion
To support earlier versions of Mac OS X, change the deployment target, not the SDK.