Well, can find this article, generally received the following requirements:
I smoked a little bit of content from Raywenderlich to do the diary, in addition, this article is not about the layout of the adaptation, but because the iOS upgrade brought by the version of the code is incompatible.
Deployment Target vs. Base SDK
In general, the Base SDK indicates the highest version you would like to support, located in the property page of the target you want to set, Build Settings > Architectures generally choose latest iOS, for example, when I wrote this log, it was 8.0.
and deployment target represents the minimum version you would like to support, located in the same Build Setting Deployment section below, where you can findiOS Deployment Target
Discover compatibility issues
This simple:
A real machine running an old system
You have so many machines.
Running the emulator
You have so many SDKs, of course, it's not impossible.
Apple's documentation
Header Files
The original text is as follows, but I really did not find command-click after jumping Ns_available_ios () and Ns_class_available_ios () These two macros, this does not indicate that there is no compatibility problem?
Sometimes the best documentation of methods and classes are contained right in the source code.
Simply Command-click The symbol you want to inspect, and Xcode would take your to it header file, where you'll find the I Nformation need along with the parameters of the preprocessor macros Ns_available_ios () and Ns_class_available_ios (). If a class or method declaration doesn ' t use either of the those availability macros, you can assume this they won ' t cause any compatibility issues.
Note:alt + click on a method would display a popover that contains these same details along with other information about T He method.
Apple offers apid diffs
This is supposed to be the most complete.
https://developer.apple.com/library/ios/releasenotes/General/iOS60APIDiffs/
https://developer.apple.com/library/ios/releasenotes/General/iOS70APIDiffs/
In turn,
Of course, the preview state is as follows:
https://developer.apple.com/library/prerelease/ios/releasenotes/General/iOS80APIDiffs/
Deploymate
This is a paid service, in short, the cost of outsourcing. The demonstration video of the dough stick help deploymate, self-turning wall
Mjgavailability
A sample header file, from Mjgfoundation, will spoof the compiler that some API has been deprecated to trigger a warning, and the usage has been made very clear in the file header, and you can try it yourself.
Resolving compatibility issues
New frameworks, classes, methods, constants, and enumerations are introduced as follows
Frameworks
In Build Phases -> Link Binary With Libraries , change the specific frame Required from Optional , this will weak link to the frame you selected
Classes
The target version may not be supported by the class, the article provides the wording of the iOS4.2, serious doubts now have a new wording, or have not supported, I hope someone left a message:
if ([SLComposeViewController class]) { //Safe to use SLComposeViewController } else { //Fail gracefully}
Methods
if ([self.image respondsToSelector:@selector(resizableImageWithCapInsets:resizingMode:)]) { //Safe to use this way of creating resizable images} else { //Fail gracefully}
If you are a class method, use a class instead of an instance:
if ([UIView respondsToSelector:@selector(requiresConstraintBasedLayout)]) { //Safe to use this method} else { //Fail gracefully}
The same method can be used to detect whether a class supports a property, such as whether a uilabel is available attributedText ,@selector(setAttributedText)
CONSTANTS/C functions
General expression extern NSString * or C language method, such as a iOS6 introduced C method ABAddressBookCreateWithOptions(...) , in the iOS5 want to not hang out can be so judged:
if (ABAddressBookCreateWithOptions != NULL) { //Safe to use}else { //Fail gracefully}
Constants are also the same:
if (&UIApplicationWillEnterForegroundNotification) { //Safe to assume multitasking support}else { //Fail gracefully}
Enumeration values
Please look at the original
Checking for the existence of enumeration or bit mask values-the kind so you would find inside an ns_enum or ns_option S Declaration-is incredibly difficult to check at runtime. Why?
Under the hood, an enumeration was just a method of giving names to numeric constants. An enum was replaced with a int when compiled, which always exists!
If you ' re faced with the situation of needing to see if a certain enumeration exists, all you can does is either explicitly Check the OS version (which isn ' t recommended) or alternatively check against another API element that is introduced at T He same time as the new enumeration value.
Note:whichever-the-sure-to-add adequate comments to any such code and consider wrapping the code in a ded icated Compatibility Helper.
Explicit version detection
NSString *osVersion = [[UIDevice currentDevice] systemVersion];, but the author does not recommend ...
Finally, fruit Official compatibility Guide: SDK compatibility guides