@(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
1
2
3
if(self.traitCollection.forceTouchCapability == UIForceTouchCapabilityAvailable) {
} Swift detection code
1self.traitCollection.forceTouchCapability == .availible
IOS11 (Xcode9)
2.1. SafeArea
IOS11 adds two new properties for UIViewController and UIView safeAreaInsets and safeAreaLayoutGuide
SafeAreaInsets are suitable for manual calculation.
SafeAreaLayoutGuide is suitable for automatic layout.
1
2
3
4
Added to UIViewController:
– (void)viewSafeAreaInsetsDidChange;
UIView added:
– (void) viewSafeAreaInsetsDidChange;
Safe Area in Storyboard is only supported for iOS9 at the very least, iOS8 users should give up
Author: is the young links: www.jianshu.com/p/721ae1f32… The copyright of the book belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please indicate the source.
When UIViewController calls – (void)viewDidLoad all of its subviews have safeAreaInsets equal to UIEdgeInsetsZero.
ViewSafeAreaInsetsDidChange call time is as follows:
1, the 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
Top = 0, left = 0, bottom = 0, right = 0
Top = 0, left = 50, bottom = 50, right = 50
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#import”Adaptive11VC.h”
staticinline UIEdgeInsets sgm_safeAreaInset(UIView *view) {
If (@ the available (iOS 11.0, *)) {
returnview.safeAreaInsets;
}
returnUIEdgeInsetsZero;
}
@interfaceAdaptive11VC ()
@end
@implementation Adaptive11VC
– (void)viewDidLoad {
[superviewDidLoad];
}
– (void)testSafeArea {
UIEdgeInsets safeAreaInsets = sgm_safeAreaInset(self.view);
NSLog(@”safeAreaInsets = %@”, NSStringFromUIEdgeInsets(safeAreaInsets));
}
– (void)viewSafeAreaInsetsDidChange {
[superviewSafeAreaInsetsDidChange];
[self testSafeArea];
}
@end
2.2, UIScrollView iOS 11 abandoned automaticallyAdjustsScrollViewInsets property of UIViewController 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.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
// method 1 :(not recommended) modify additional security zones
If (@ the available (iOS 11.0, *)) {
self.additionalSafeAreaInsets = UIEdgeInsetsMake(-44, 0, 0, 0);
}
else{
// Fallback on earlier versions
}
// method 2 :(recommended) disable automatic adjustment
If (@ the available (iOS 11.0, *)) {
// applies to the specified UIScrollView
self.tableView.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
// Works with all UIScrollView
UIScrollView.appearance.contentInsetAdjustmentBehavior = UIScrollViewContentInsetAdjustmentNever;
}
else{
self.automaticallyAdjustsScrollViewInsets = NO;
}
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.
The LocalAuthentication 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:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#import/**
Check if 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 “);
}
}
/ * *
Use when verifying that TouchID is available
* /
– (void)excuteBiometrics {
LAContext *context = [[LAContext alloc] init];
The context. LocalizedFallbackTitle = @ “custom title”;
[context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
LocalizedReason :@” Why write here with TouchID”
reply:^(BOOL success, NSError * _Nullable error) {
if( success ) {
// The fingerprint verification succeeded
}
else{
switch(error.code) {
caseLAErrorUserFallback:{
NSLog(@” user selects password “);
break;
}
caseLAErrorAuthenticationFailed:{
NSLog(@” validation failed “);
break;
}
caseLAErrorUserCancel:{
NSLog(@” user cancel “);
break;
}
caseLAErrorSystemCancel:{
NSLog(@” system cancel “);
break;
}
// There are three cases that will not occur if you check ahead to see if TouchID is available
caseLAErrorPasscodeNotSet:{
break;
}
caseLAErrorTouchIDNotAvailable:{
break;
}
caseLAErrorTouchIDNotEnrolled:{
break;
}
default:
break;
}
}
}];
}
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
1
2
3
4
5
6
7
8
9
{
“extent”: “full-screen”,
“idiom”: “iphone”,
“subtype”: “2436h”,
“filename”: “1125_2436.png”,
Minimum – system – “version” : “11.0”,
“orientation”: “portrait”,
“scale”: “3x”
}
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.
If you want to support older versions of iOS 11 or below, it is recommended to configure all keys in info.plist (even though
1
2
3
4
5
NSLocationAlwaysUsageDescription 11 and above in the iOS version no longer use) :
NSLocationWhenInUseUsageDescription
NSLocationAlwaysAndWhenInUseUsageDescription
NSLocationAlwaysUsageDescription
NSLocationAlwaysAndWhenInUseUsageDescription / / a new iOS 11 Key.
2.7 UIKit’s Bars changes in iOS11
IOS10 (Xcode8)
3.1, (according to? Safe!) Plug-in to cancel
Xcode8 has removed tripartite plugins (many excellent plugins that would have greatly improved efficiency) and replaced them with Extension
Xcode 8 Extension is recommended
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.
Solutions:
Only need the info. Add NSContactsUsageDescription plist key, value their optional fill in can, here are the corresponding key (Source Code mode) :
1 nsphotolibraryusagedescriptionapp need your approval to access photo album NSCameraUsageDescriptionApp need your approval, can access the camera NSMicrophoneUsageDescriptionApp needs Your approval to access the microphone NSLocationUsageDescriptionApp need your approval, NSLocationWhenInUseUsageDescriptionApp need your approval to access location, to access location NSLocation during use AlwaysUsageDescriptionApp need your approval, can always access the location NSCalendarsUsageDescriptionApp need your approval, to access the calendar NSRemindersUsageDescriptionApp need your approval, To access remind NSMotionUsageDescriptionApp need your approval, can access to sports and fitness NSHealthUpdateUsageDescriptionApp need your approval, can access health updates NSHealthShareUsageDescriptionApp need your approval to access health share NSBluetoothPeripheralUsageDescriptionApp need your approval, can access the bluetooth NSAppleMusicUsageDes CriptionApp requires your consent to access the media repository
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.).
Mode 1: Prefs :root= A service is applicable to the operating system whose OS size is smaller than iOS10.
NSURL *url = [NSURL URLWithString:@”prefs:root=WIFI”];
Method 2: prefs:root=bundleID This parameter is applicable to oss greater than or equal to iOS8 but smaller than iOS10
NSURL *url = [NSURL URLWithString:@”prefs:root=bundleID”];
The third way: UIApplicationOpenSettingsURLString applies to greater than or equal to iOS8 system
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
// iOS version >= 10.0
{
NSURL *url = [NSURL URLWithString:UIApplicationOpenSettingsURLString];
if([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
}
}
return;
// iOS version >= 10.0
// But! This is not recommended, as the official documentation states:
// URL is now considered a private API and use will result in app rejection
.
// While it is possible to avoid Apple’s detection, there is a risk that your app will be rejected if Apple catches you using it in this way.
{
NSURL *url = [NSURL URLWithString:@”APP-Prefs:root=WIFI”];
if([[UIApplication sharedApplication] canOpenURL:url]) {
If (@ the available (iOS 10.0, *)) {
[[UIApplication sharedApplication] openURL:url
options:@{}
completionHandler:nil];
} else{
// Fallback on earlier versions
}
}
}
// iOS version < 10.0
{
NSURL *url = [NSURL URLWithString:@”prefs:root=WIFI”];
if([[UIApplication sharedApplication] canOpenURL:url]) {
[[UIApplication sharedApplication] openURL:url];
}
}
Jump destination
If the iOS version is <= iOS7, you can only switch to the system setting page
IOS version >= iOS8, you can switch to the Settings page of the third-party application. Use prefs:root=bundleID. BundleID is the unique ID of your third-party application project
IOS version >= iOS10, you can switch to your own application Settings, but not 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.
Solution 1:
The simplest solution is to turn Bitcode off first: change Build settings-build options-enable Bitcode to NO.
Solution 2:
Remove platform SDKS that do not support BitCode, or find alternatives that support 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:
1NSAppTransportSecurity NSAllowsArbitraryLoads
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:
Original article: www.cocoachina.com/ios/2019020…