简体   繁体   中英

Best way to determine lowest possible iOS / macOS deployment target

Is there a way to, given an iOS or macOS codebase, determine the lowest possible IPHONEOS_DEPLOYMENT_TARGET or MACOSX_DEPLOYMENT_TARGET I can safely set for a project, in order to capture the largest potential number of supported devices? I don't want to just arbitrarily say "iOS 11" or something because that would leave users of older operating systems out. On the other hand, every API call requires a certain version of the OS, and I don't have an accounting of every single API call I make, nor do I want to look them all up.

For example, maybe one out of the thousands of APIs my app calls requires iOS 10 and will fail on iOS 9. Is there a way to tell? Just setting IPHONEOS_DEPLOYMENT_TARGET to 8.0 seems to compile fine (no warnings), but that doesn't necessarily mean I'm good to deploy on 8.0 devices.

This similar 8-year-old question suggests there was no such tool to at the time. Wondering if anything has changed since.

Xcode 10 (and Xcode 9) will warn you if you have any APIs in use that may be an issue. For example, if your Deployment Target is set to iOS 11 and you attempt to use an API added in iOS 12, Xcode will warn you.

So update your project's or target's Deployment Target to whatever you want and let Xcode give you warnings about such APIs or even deprecated APIs.

Then you can use the "fix" button on the warning to add the appropriate if (@available ...) check around the newer API and then you can add whatever code is needed in the else to support the older iOS version.

If you feel you got too many such API issues, change your Deployment Target as desired.

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