简体   繁体   中英

Xcode compiling SKStoreProductViewController on iOS 5?

As far as the docs say, SKStoreProductViewController is iOS 6 and up but Xcode compiles it successfully on iOS 5.1. And worst of that, even the binary in theory being compiled for iOS 5.1, I can run it perfectly on devices with iOS 6. I have no devices with 5.1 to test.

Is it a bug, right?

If this is a bug, we cannot trust Xcode to warn us of stuff that will not work on iOS versions previous than the current one, making the development risking of some crash if we use by mistake some stuff that is not on that iOS.

Is it possible to make Xcode warn us of things like that?

thanks.

There is a difference between the Base SDK and Deployment Target used in an Xcode project. The Base SDK is often set to the latest SDK (in your case 6.1) while your Deployment Target is set to the minimum version you claim to support.

Since Xcode is using the Base SDK, it's perfectly happy - and valid - to use SKStoreProductViewController in your code. It's up to you, if you're claiming to support versions lower than iOS 6, to structure your code so that iOS 6 APIs are never used when running in a lower OS version.

This is a good example of where testing on each OS you claim to support is necessary. The compiler won't catch this error and it'll only be present at runtime.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM