Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

xcode

ios

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

like image 573
Vladimir Gritsenko Avatar asked Aug 11 '13 08:08

Vladimir Gritsenko


People also ask

How do I check my iOS SDK version?

To find out the version number of each framework, navigate to the . framework file, locate and open the Info. plist file. If you are using an IDE (Integrated Development Environment), such as Xcode, look for the value for the key Bundle versions string.

What is SDK version in iOS?

The iOS SDK is a software development kit that helps developers create native applications for Apple's iOS devices and platforms. The iOS SDK was formerly known as the iPhone SDK.

How does iOS SDK work?

The iOS SDK, combined with Xcode, helps developers write iOS applications using officially supported programming languages, including Swift and Objective-C. An . ipa (iOS App Store Package) file is an iOS application archive file which stores an iOS app.

Is the SDK for programming an app for iOS?

The iOS SDK comprises all the libraries you need to write iOS apps, as well as the iOS Simulator for you to try out your apps on your Mac. The SDK is included with the Xcode tool, which is used for creating iOS and Mac applications.


2 Answers

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

like image 75
miho Avatar answered Oct 20 '22 00:10

miho


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

like image 44
Michael Dautermann Avatar answered Oct 19 '22 23:10

Michael Dautermann