How can I get the version of the base SDK in code? I am currently building for iOS in XCode 6 and using the base SDK 8.1 . I would like to know if there is any define with the value of the SDK to be able to test it and allow building with different base SDKs.
-
Correct me if I am wrong but you must use the latest SDK to submit to the Store. Why would you change the base SDK? Do you want to have a different deployment target? – Teddy Feb 05 '15 at 14:19
-
No, I am not talking about a different deployment target. I was asked to make the project so that it can be built in XCode 5 and 6, without people having to install new base SDKs. Do you know a way to get that value? – Scorpio Feb 05 '15 at 14:23
-
AFAK you need to install xcode 5 along with xcode 6 in this case and switch between the two using xcode-select. You may face some issues however. I never tried myself. – Teddy Feb 05 '15 at 14:29
2 Answers
You can find out the version of the current Foundation framework that the code is running against by checking the value of NSFoundationVersionNumber
.
If you check out the NSObjCRuntime.h
you will find the various version numbers listed in there.
As in regards to building against different versions of the SDK; Apple stops App Store uploads if you don't build against the latest SDK once the cut off date has come into effect - i.e. new apps submitted now must be build against iOS 8 SDK.
What you can however do, is have a lower iOS Deployment Target (this you can find in your project's settings). This will allow for your app to run on older iOS versions, but it will still be built against the latest SDK. Do note though, it is your responsibility to ensure that you do not use any new APIs without first ensuring the current environment supports them e.g. UITextField's selectable property. If you call that whilst running on iOS 6, your app will crash.

- 1,222
- 10
- 19
-
I couldn't find some official rule that prevents an app from being approved if not built against latest base SDK. Could you provide a link to that? – Scorpio Feb 05 '15 at 14:46
-
It's fairly widely reported in the Apple circles: https://developer.apple.com/news/?id=01192015a – MultiColourPixel Feb 05 '15 at 14:51
-
Thanks for that. I am not really in "the Apple circle" yet. I saw that post, but was unable to understand it properly :(. I found a way to add what I wanted using __IPHONE_OS_VERSION_MAX_ALLOWED < __IPHONE_8_0, but I start to think it's not necessary. Thanks! – Scorpio Feb 05 '15 at 14:59
This can be done using __IPHONE_OS_VERSION_MAX_ALLOWED (which is the same version as the base SDK version). That can be compared to __IPHONE_8_0 where 8_0 is the iOS release.
For example, at this point you can use the baseSDK 8.0 or 8.1.

- 1,124
- 1
- 11
- 28