@(for IOS versions)

[TOC]

IOS12 (Xcode10)

1.1 Project error after upgrade Xcode10

Multiple info.plists are not allowed

Xcode10 is the latest New Build System(Default) selected by Default. Multiple info.plists are not allowed in this Build System environment

Solution 1 :(recommended)

Switch build System to Legacy Build System, in other words, to the old build system, and you’re done. Xcode->File->Project Settings-> Build System -> Legacy Build System.

Solution 2:

Delete other info.plist files.

IOS 12 removed libstdc++ and replaced it with libc++

Libstdc++ libraries in Xcode10 (libstdc++, libstdc++.6, libstdc++6.0.9) are deprecated. If you develop your own use, consider migrating as soon as possible.

1.2. IPhone XR does not support 3D-Touch

OC detection code
if (self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable) {

}
Copy the code
Swift detection code
self.traitCollection.forceTouchCapability == .availible
Copy the code

IOS11 (Xcode9)

2.1. SafeArea

IOS11 adds two new properties for UIViewController and UIView safeAreaInsets and safeAreaLayoutGuide

  • safeAreaInsetsSuitable for manual calculation.
  • safeAreaLayoutGuideSuitable for automatic layout.
New in UIViewController: - (void) viewSafeAreaInsetsDidChange; UIView: - (void)safeAreaInsetsDidChange;Copy the code

Safe Area in Storyboard is only supported for iOS9 at the very least, iOS8 users should give up

When UIViewController calls – (void)viewDidLoad all of its subviews have safeAreaInsets equal to UIEdgeInsetsZero.

ViewSafeAreaInsetsDidChange call time is as follows:

  • 1.viewDidLoad
  • 2,viewWillAppear
  • 3,viewSafeAreaInsetsDidChange
  • 4,viewWillLayoutSubviews
  • 5,viewDidAppear

Could be attained only after calling viewSafeAreaInsetsDidChange, view and viewcontrollers SafeArea (UIEdgeInsets). So in viewDidload there’s a problem with setting up the SafeArea interface.

IPhone X: +44 with navigation

Vertical screensafeAreaInsets = (top = 44, left = 0, bottom = 34, right = 0)
landscapesafeAreaInsets = (top = 0, left = 44, bottom = 21, right = 44)
#import "Adaptive11VC.h"
static inline UIEdgeInsets sgm_safeAreaInset(UIView *view) {
    if(@ the available (iOS 11.0, *)) {return view.safeAreaInsets;
    }
    return UIEdgeInsetsZero;
}

@interface Adaptive11VC ()
@end
@implementation Adaptive11VC
- (void)viewDidLoad {
    [super viewDidLoad];
}
- (void)testSafeArea {
    UIEdgeInsets safeAreaInsets = sgm_safeAreaInset(self.view);
    NSLog(@"safeAreaInsets = %@", NSStringFromUIEdgeInsets(safeAreaInsets));
}
- (void)viewSafeAreaInsetsDidChange {
    [super viewSafeAreaInsetsDidChange];
    [self testSafeArea];
}
@end
Copy the code

2.2, UIScrollView

IOS 11 abandoned UIViewController automaticallyAdjustsScrollViewInsets attributes, contentInsetAdjustmentBehavior attribute has been added, So adjustedContentInset affects adjustedContentInset when it is outside the safe zone. In iOS11, adjustedContentInset determines the distance between the tableView content and the edge. So you need to set the UIScrollView contentInsetAdjustmentBehavior properties.

// method 1 :(not recommended) modify additional security zonesif(@ the available (iOS 11.0. *)) {self. AdditionalSafeAreaInsets = UIEdgeInsetsMake (- 44, 0, 0, 0). }else{// Fallback on earlier versions} // method 2 :(recommended) set it to no automatic adjustmentif(@ the available (iOS 11.0, *)) {/ / applied to specified UIScrollView self. The tableView. ContentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; / / function with all the UIScrollView UIScrollView. Appearance. ContentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever; }else {
    self.automaticallyAdjustsScrollViewInsets = NO;
}
Copy the code

2.3. Tableview problem

IOS11 starts with UITableView turning on automatic row height estimation, estimatedRowHeight estimatedSectionHeaderHeight EstimatedSectionFooterHeight three highly estimated by default 0 into UITableViewAutomaticDimension, if you don’t realize – tableView: viewForFooterInSection: And – tableView: ViewForHeaderInSection:, So estimatedRowHeight estimatedSectionHeaderHeight EstimatedSectionFooterHeight three highly estimated by default 0 into UITableViewAutomaticDimension, lead to high calculation is wrong, can produce blank. The solution is to implement the corresponding method or set these three properties to 0.

2.4. LocalAuthentication

The local authentication framework provides the ability to request authentication from a user with a specified security policy (password or biometric characteristics). For example, to require the user to authenticate only with Face ID or Touch ID, use the following code:

#import <LocalAuthentication/LocalAuthentication.h>/** Check whether TouchID is available */ - (void)checkBiometrics {LAContext *context = [[LAContext alloc] init]; BOOL success = [context canEvaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics error:nil];if ( success ) {
        NSLog(@"can use");
    }
    else {
        NSLog(@"can`t use "); }} /** excuteBiometrics {LAContext *context = [[LAContext alloc] init]; context.localizedFallbackTitle = @"Custom title";
    [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
            localizedReason:@"Why did I write here with TouchID?"
                      reply:^(BOOL success, NSError * _Nullable error) {
        if(SUCCESS) {// Fingerprint verification succeeded}else {
            switch (error.code) {
                case LAErrorUserFallback:{
                    NSLog(@"User chooses to enter password");
                    break;
                }
                case LAErrorAuthenticationFailed:{
                    NSLog(@"Verification failed");
                    break;
                }
                case LAErrorUserCancel:{
                    NSLog(@"User Cancel");
                    break;
                }
                case LAErrorSystemCancel:{
                    NSLog(@"System cancelled");
                    break; } // There are three cases that will not occur if you check ahead to see if TouchID is availablecase LAErrorPasscodeNotSet:{
                    break;
                }
                case LAErrorTouchIDNotAvailable:{
                    break;
                }
                case LAErrorTouchIDNotEnrolled:{
                    break;
                }
                default:
                    break; }}}]; }Copy the code

2.5. Adaptation of startup diagram

Method 1: Launch launchscreen. storyboard

Method 2: Use the LaunchImage in Assets

  • Add a 1125 by 2436 image to Brand Assets
    • Open the assets. xcassets folder and go to Brand Assets
    • Right-click Show in Finder
    • Add a 1125 by 2436 image
  • Modify the Contents. Json file and add the following
{
	"extent" : "full-screen"."idiom" : "iphone"."subtype" : "2436h"."filename" : "1125_2436.png"."minimum-system-version" : "11.0"."orientation" : "portrait"."scale" : "3x"
}
Copy the code

2.6. Localization

Must support the When In Use In iOS 11 authorization model (NSLocationWhenInUseUsageDescription), In 11 of the iOS, In order to avoid the developers to provide only request Always authorization model this kind of situation, to join this limit, If the When In Use authorization mode is not provided, the Always authorization mode cannot be used.

11 if you want to support the old version, namely the iOS system version below, then suggested in the info. All configured in the plist Key (even NSLocationAlwaysUsageDescription 11 and above in the iOS version no longer use) :

NSLocationWhenInUseUsageDescription NSLocationAlwaysAndWhenInUseUsageDescription NSLocationAlwaysUsageDescription NSLocationAlwaysAndWhenInUseUsageDescription / / a new iOS 11 Key.Copy the code

2.7,UIKit’s Bars in iOS11

IOS10 (Xcode8)

3.1, (according to? Safe!) Plug-in to cancel

Xcode8 has removed tripartite plugins (many excellent plugins that would have been much more efficient) and has replaced Xcode8 Extension recommendations with Extension

3.2. Certificate issues

Automatically manage Signing is provided to facilitate user management. Need to enter the developer account! If you do not have an account, you can also select the corresponding certificate in Debug, Realease, and inHouse modes.

3.3 Privacy data access problems

IOS10, apple has strengthened the protection of private data, to make a suitable for private data permission, iOS10 call camera, access to the address book, access to the album, etc., to add access description in the info.plist, otherwise your previous project involving these permissions will directly crash.


Solution: just in the info. Add NSContactsUsageDescription plist key, value their optional fill in can, here are the corresponding key (Source Code mode) :

< key > NSPhotoLibraryUsageDescription < / key > < string > App need your approval, to access photo album < / string > <key>NSCameraUsageDescription</key><string>App requires your consent to access the camera </string> < key > NSMicrophoneUsageDescription < / key > < string > App need your approval, to access the microphone < / string > < key > NSLocationUsageDescription < / key > < string > App need your approval, can access position < / string > < key > NSLocationWhenInUseUsageDescription < / key > < string > App need your approval, can access position during use < / string > < key > NSLocationAlwaysUsageDescription < / key > < string > App need your approval, can always access the location < / string > < key > NSCalendarsUsageDescription < / key > < string > App need your approval, to access the calendar < / string > < key > NSRemindersUsageDescription < / key > < string > App need your approval, can access reminders < / string > <key>NSMotionUsageDescription</key><string>App requires your consent to access sports and Fitness </string> < key > NSHealthUpdateUsageDescription < / key > < string > App need your approval, can access health update < / string > < key > NSHealthShareUsageDescription < / key > < string > App need your approval, can access health share < / string > < key > NSBluetoothPeripheralUsageDescription < / key > < string > App need your approval, can access the bluetooth < / string > < key > NSAppleMusicUsageDescription < / key > < string > App need your approval, to access the media database < / string >Copy the code
Private data Corresponding to the key value
Photo album NSPhotoLibraryUsageDescription
The camera NSCameraUsageDescription
The microphone NSMicrophoneUsageDescription
location NSLocationUsageDescription
Access locations during use NSLocationWhenInUseUsageDescription
Always access location NSLocationAlwaysUsageDescription
The calendar NSCalendarsUsageDescription
reminders NSRemindersUsageDescription
Sports and Fitness NSMotionUsageDescription
Health updates NSHealthUpdateUsageDescription
Healthy share NSHealthShareUsageDescription
bluetooth NSBluetoothPeripheralUsageDescription
Media database NSAppleMusicUsageDescription

3.4 jump to the privacy data setting page in the APP

IOS 10 eliminates URL Scheme for all system Settings, which means you can no longer jump directly to the system Settings page (WiFi, cellular data, location, etc.).

Jump way

Method 1: prefs:root= A service is applicable to oss smaller than iOS10. NSURL *url = [NSURL URLWithString:@”prefs:root=WIFI”];


NSURL * URL = [NSURL URLWithString:@”prefs:root=bundleID”];


Three: UIApplicationOpenSettingsURLString applies to greater than or equal to iOS8 system NSURL * url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];

/ / iOS version > = 10.0 {NSURL * url = [NSURL URLWithString: UIApplicationOpenSettingsURLString];if([[UIApplication sharedApplication] canOpenURL:url]) { [[UIApplication sharedApplication] openURL:url]; }}return; // iOS version >= 10.0 // But! // 'URL is now considered a private API and use will resultinApp rejection '. // It's possible to get past Apple's detection, but if Apple finds out you do it it runs the risk of being rejected"APP-Prefs:root=WIFI"];
    if ([[UIApplication sharedApplication] canOpenURL:url]) {
        if (@available(iOS 10.0, *)) {
            [[UIApplication sharedApplication] openURL:url 
								               options:@{} 
								     completionHandler:nil];
        } else{// Fallback on earlier versions}}} // iOS < 10.0 {NSURL *url = [NSURL URLWithString:@"prefs:root=WIFI"];
    if([[UIApplication sharedApplication] canOpenURL:url]) { [[UIApplication sharedApplication] openURL:url]; }}Copy the code

Jump destination

  • IOS Version<= iOS7, you can only go to the system Settings page
  • IOS Version>= iOS8You can jump to the Settings page of the third-party application. useprefs:root=bundleID ,bundleIDIs the unique ID of your third-party application project
  • IOS Version>= iOS10, you can jump to application Settings, but cannot jump to system Settings

3.5. Font changes

Apple’s default fonts will vary from version to version of iOS, with fonts getting bigger in iOS10. Cause the original display to be wrong, cause… The emergence of. There is no good solution for the moment, you need to adapt yourself one by one!

3.6 optimization of UICollectionViewCell

  • Prior to iOS 10, cells could only be retrieved from the reuse queue, walked through the lifecycle again, and called cellForItemAtIndexPath to create or generate a cell.

  • In iOS 10, a cell is stored for a certain amount of time, which means that when a user slides a cell off the screen, if they slide it back on, the cell doesn’t have to go through its life cycle again, just call the willDisplayCell method to reappear on the screen.

  • In iOS 10, the system loads cells one by one, rather than one line by line, which improves performance.

  • New pre-loading for iOS 10

3.7, UIRefreshControl

In iOS 10, UIRefreshControl can be used directly in UICollectionView and UITableView without the UITableViewController. RefreshControl is now an attribute of UIScrollView.

3.8, UserNotifications(UserNotifications)

  • IOS 10. All the relevant notice is unified to UserNotifications framework framework. Added contents of revocation, update and notification that can be modified in the middle. Notifications are no longer simple text. You can add videos, images, custom notifications, and more.

  • IOS 10 is much easier to manage than previous notifications and has been massively optimized, which is a good thing for developers.

  • IOS 10 is starting to optimize permissions, making it easier to apply for permissions (local and remote notifications are integrated in one method).

IOS9 (Xcode7)

4.1, Bitcode

Xcode7 has Bitcode enabled by default, but if the third-party library we are using is compiled without Bitcode enabled, the main project will compile without Bitcode. Bitcode is one of Apple App Stochastic mechanisms that reduces the size of packages to be installed. The App Store will compile this Bitcode into an executable 64-bit or 32-bit program.

The simplest solution is to turn Bitcode off first: change Build settings-build options-enable Bitcode to NO.

Solution 2: Remove the platform SDK that does not support BitCode, or find a substitute that supports BitCode, or contact the SDK to support BitCode.

4.2. The HTTP request fails

IOS9 does not support HTTP requests by default, so you need to switch to the more secure HTTPS (TLS 1.2 by default). Apple also provides a configuration that allows all less secure network requests to be used. The solution is to add the following configuration to info.plist:

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>
Copy the code

If more complex, you can also specify a whitelisted domain name and declare the lowest version of TLS supported. It is also important to note that even if the above configuration is written, HTTP javascript or CSS will not be loaded in HTTPS pages, because Apple believes this reduces the security of the page.

4.3 canOpenUrl restriction

CanOpenUrl can be used to determine whether a user has installed an APP. CanOpenUrl is limited to 50 schemes in iOS9, perhaps for the sake of user privacy. If you are compiling with Xcode7, you need to declare these schemes in plist. If you are not declared, you will return NO:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>weixin</string>
    <string>wechat</string>
</array>
Copy the code

4.4 Problems of UIStatusBar

Deprecated method in iOS9

// Change the status bar to white //'setStatusBarStyle(_:animated:)' was deprecated inIOS 9.0: Use - [UIViewController preferredStatusBarStyle] UIApplication. Shared. SetStatusBarStyle (. LightContent, animated:true// Hide the status bar //'setStatusBarHidden(_:with:)' was deprecated inIOS 9.0: Use - [UIViewController prefersStatusBarHidden] UIApplication. Shared. SetStatusBarHidden (true, with: .fade)
Copy the code

I’m going to use the following two methods

-[UIViewController preferredStatusBarstyle]
-[UIViewController preferredStatusBarHidden]
Copy the code

References:

IOS12 adaptation

iOS12AdaptationTips

About the iPhone X fit

IOS11 for iPhoneX summary

IOS 10 adaptation summary

Let’s talk about some ways to jump through your system Settings after the iOS 10 update

IOS 10 Calls Settings (full)

IOS TouchID authentication and Keychain authentication are used together

iOS10AdaptationTips

Adapter iOS9

Summary of wechat iOS 9 adaptation

iOS9AdaptationTips