Vladimir Gritsenko
Vladimir Gritsenko

Reputation: 1683

Is there a macro that denotes the iOS SDK version against which the code is compiled?

I.e., is it possible to know if my code is compiled under SDK 5.1, or 6.0, or any other version?

Upvotes: 8

Views: 7083

Answers (2)

miho
miho

Reputation: 12085

#ifdef __IPHONE_6_0
    // Will be ignored when compiled under SDK 5.1
#endif

When you are compiling under iOS SDK 5.1 or any other older SDK there is no #define for __IPHONE_6_0, so checking if the macro is defined helps to check the SDK version.

Upvotes: 14

Michael Dautermann
Michael Dautermann

Reputation: 89549

Take a look at the file "Availability.h" and "AvailabilityInternal.h" in the iOS SDK and you'll see conditionals that you may be able to make use of. The Apple OpenSource ones that I linked to (which I found in this closely related question) aren't the same ones that you'll find in your SDK.

For example, I see a define for "__IPHONE_OS_VERSION_MIN_REQUIRED" and if you want to compile this code only on iOS 6 & newer, you'd make certain to have this set to "__IPHONE_6_0".

Upvotes: 2

Related Questions