Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an iPhone equivalent of MAC_OS_X_VERSION_MIN_REQUIRED?

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?

Update:

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?

Update 2:

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.

like image 561
Daniel Dickison Avatar asked Mar 28 '09 00:03

Daniel Dickison


2 Answers

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

like image 108
cdespinosa Avatar answered Sep 20 '22 16:09

cdespinosa


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).

like image 22
Becca Royal-Gordon Avatar answered Sep 22 '22 16:09

Becca Royal-Gordon