On Sep 19, 2008, at 4:43 PM, Dan Wood wrote:
Hi folks, I wonder if anybody can figure this puppy out.
We have a project (with dependent projects; it's pretty complex) that is set for a 10.4 deployment target, by specifying these settings in the .xcconfig file(s):
MACOSX_DEPLOYMENT_TARGET = 10.4
SDKROOT = /Developer/SDKs/MacOSX10.4u.sdk
When building under 'Debug' or 'Release' from Xcode itself, everything is fine. But I want to be able to build from the command line (for instance, to use the awesome Clang static analyzer).
I've tried either specifying the SDK on the command line ("-sdk macosx10.4") or not.
What I'm finding is that xcodebuild seems to be ignoring my request for deploying for a 10.4 base.
I know that for two reasons:
1) I get compile errors where QTMovieLayer.h, in the 10.4u SDK, is trying to access CALayer, something which is only defined in Leopard!
This Leopard-only code will only be compiled if this evaluates true:
#if (QTKIT_VERSION_MAX_ALLOWED >= QTKIT_VERSION_7_2) && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_5)
So this means that
2) I have a method that should only be compiled if MAC_OS_X_VERSION_MIN_REQUIRED <= MAC_OS_X_VERSION_10_4. The compiler has errors finding my method, which means that MAC_OS_X_VERSION_MIN_REQUIRED is set to MAC_OS_X_VERSION_10_5, not MAC_OS_X_VERSION_10_4
I've even tried setting MACOSX_DEPLOYMENT_TARGET=10.4 in the environment before calling xcodebuild (or, indirectly, via scan-build).
Anybody have any suggestions on how to diagnose what's going on?
I have a few ideas of things to check or try:
1) Verify which configuration is being built when you do an xcodebuild. If you don't pass a -configuration flag, then it will use the default configuration as defined in the project inspector's Configurations tab.
2) Verify that the xcconfig files are set for the configuration you're building for. Each configuration for each target or project can have a different xcconfig file.
3) Setting the deployment target will set the -mmacosx-version-min= flag passed to the compiler. Check your compilation lines to see whether that's being passed.
4) Add a dummy shell script build phase which just prints the environment variables passed to it and see what MACOSX_DEPLOYMENT_TARGET is set to.
5) Make sure none of your targets have accidentally overridden the setting to be (for example) empty - or anything else for that matter. A setting at the target level will override that target's xcconfig file.
In general, defining an SDK will default the deployment target to that SDK's OS version. However, setting it to be empty will cause it to use the compiler default, which on Xcode 3.0 and later is the version of the OS you're building on.
Setting MACOSX_DEPLOYMENT_TARGET in the environment will often have no effect, because the environment is one of the very lowest (least precedence) build settings dictionaries in Xcode, so practically anything set above it (including Xcode defaults such as the one I mentioned in the previous paragraph) will override it. To force xcodebuild to treat it with very high precedence, pass it on the command like. For example:
xcodebuild MACOSX_DEPLOYMENT_TARGET=10.4
You could do that as a last resort, although it would still be interesting to figure out why the xcconfig file value isn't being used.
--
Michael Rawdon
email@hidden
Xcode Developer
Apple Inc., Cupertino CA