I would like to conditionally include code for an iPhone app depending on which version of the SDK I'm compiling against. On Mac OS X, there is the MAC_OS_X_VERSION_MIN_REQUIRED
preprocessor macro which gets set to the value of the MACOSX_DEPLOYMENT_TARGET
build setting by the compiler. Is there an equivalent on the iPhone?
I've set IPHONE_DEPLOYMENT_TARGET
to 3.0 in the build settings, but Xcode is passing -D__IPHONE_OS_VERSION_MIN_REQUIRED=20000
and -mmacosx-version-min=10.5
to GCC. Shouldn't the first one be 30000
and the second one be -miphoneos-version-min=3.0
? What am I doing wrong?
Looks like I wasn't doing anything wrong. __IPHONE_OS_VERSION_MIN_REQUIRED
and -miphoneos-version-min
are both set correctly when building for a device -- it's only wrong when using the iPhone Simulator SDK. I think it's a bug in the simulator SDK.
See Availability.h
#if __IPHONE_OS_VERSION_MIN_REQUIRED >= __IPHONE_2_0
etc.
http://developer.apple.com/iphone/library/documentation/DeveloperTools/Reference/XcodeBuildSettingRef/1-Build_Setting_Reference/build_setting_ref.html#//apple_ref/doc/uid/TP40003931-CH3-SW156
There are preprocessor macros that are defined for each version of the OS. For example, if __IPHONE_OS_3_0
is defined, then you're building against the 3.0 SDK (or possibly later, I'm not certain).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With