On Feb 27, 2007, at 7:58 AM, Shawn Erickson wrote: I suggest you set the SDK to the version of OS that you want to be able to use API from (say 10.4). As needed you can temporarily specify the max OS version to be 10.2 (MAC_OS_X_VERSION_MAX_ALLOWED) to cause the availability macros to complain about usage of post 10.2 API so that you can make sure you are doing the correct runtime checks.
There are three fairly simple mappings that describe what the original poster wants to do. As with memory management, please don't derive your own rules of thumb. In particular, please do not shortcut the build settings and modify the AvailabilityMacros directly.
(1) The SDK is the maximum version of Mac OS X you're going to use features from. This is specified by the SDKROOT build setting, which if necessary can be specified separately for each architecture. The way you do this is to create custom build settings named SDKROOT_i386 and SDKROOT_ppc and specify their values; you can do so at either the project or target level, or in an xcconfig file; it's up to you how you want to structure your project.
(2) The Mac OS X Deployment Target is the minimum version of Mac OS X you want your software to run on, e.g. "10.2" or "10.4". This is specified by the MACOSX_DEPLOYMENT_TARGET build setting, which if necessary can be specified separately for each architecture. The way you do this is to create custom build settings named MACOSX_DEPLOYMENT_TARGET_i386 and MACOSX_DEPLOYMENT_TARGET_ppc and specify their values; you can do so at either the project or target level, or in an xcconfig file; it's up to you how you want to structure your project.
(3) The GCC Version is the version of GCC that you want to build your software with. This is specified by the GCC_VERSION build setting, which if necessary can be specified separately for each architecture. Specifically, if your software needs to run on a PowerPC-based Mac on something prior to Mac OS X 10.3.9, you must compile the PowerPC side of your software with GCC 3.3 rather than GCC 4.0. The way you do this is to create a custom build settings named GCC_VERSION_ppc and specify its value as "3.3"; you can do so at either the project or target level, or in an xcconfig file; it's up to you how you want to structure your project.
Do not modify the MAC_OS_X_VERSION_MAX_ALLOWED preprocessor definition directly!!!
It will be set correctly for your code as a side effect of #1 and #2. What's more, #1 and #2 can have other side-effects, such as side-effects on linking behavior, that are important to being able to run on the specified version of Mac OS X.
For one example, if our original poster wants his software to run on PowerPC-based Macs running Mac OS X 10.2, but wants to take advantage of Mac OS X 10.4 features where available, he needs to set the following build settings:
# Settings for all architectures SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk
# Settings for PowerPC-based Macs MACOSX_DEPLOYMENT_TARGET_ppc = 10.2 GCC_VERSION_ppc = 3.3
# Settings for Intel-based Macs MACOSX_DEPLOYMENT_TARGET_i386 = 10.4 GCC_VERSION_i386 = 4.0
The deployment target in particular must be set correctly. This is because the deployment target setting affects weak linking behavior. Weak linking means you can build against the 10.4 Universal SDK even for PowerPC-based Macs, and take advantage of 10.4 features when running on 10.4, but still launch and detect that the features are missing (and should not be invoked) on 10.2.
-- Chris
|