iOS development adapts to iOS10 and Xcode8

Now on Apple's official website, we can already download the GM version of Xcode8. In the early morning of September 14th, Apple will officially launch the push of the iOS10 system. At this time, the adaptation of iOS10 is imminent. I don't know. Xcode8 beat version, have children's shoes downloaded and tried it? As far as my use is concerned, I feel that Apple is still in constant pits, but it is also making progress. Let me talk about the adaptation of iOS10 and some points of attention in the use of Xcode8.

1. Certificate Management

After opening the project with Xcode8, the following picture is more obvious. This is a new feature of Apple that can help us manage certificates automatically. It is recommended that you check this Automatically manage signing (Ps. But when I used the beat2 version, it was completely impossible. The GM version was amazing and good.)


QQ20160913-8.png-96.9kB

Here's my list of possible problems:

1. A screenshot of Xcode without setting up a developer account


QQ20160913-0.png-38.5kB


The solution is: you can add an Apple account in the preferences of Xcode.

2. Screenshots when the device machine is not added to the developer's Device


QQ20160913-2.png-33.7kB


The solution is: after you add the device to the development machine on the official website, you can accompany the description file and re-create the next description file.

3. Normal situation: Xcode configures the picture after logging in to the developer account, just wait patiently.


QQ20160913-1.png-25.1kB


Picture after waiting


QQ20160913-3.png-27kB

2. Notes on Xib files

After opening the xib file with Xcode8, the prompt shown below will appear.


QQ20160913-9.png-41.7kB


You can choose Choose Device.
After that, you will find that the layout is messed up, and you only need to update the frame. As shown below


QQ20160913-11.png-113.2kB
  • Note: If you follow the above steps, an error will be reported when you open Xib with Xcode7,

QQ20160913-12.png-32.3kB
  • Solution: need to delete Xib inside
    <capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
    This sentence, and change the toolsVersion in < document > and the version in < plugIn > to the value in your normal xib file
    , but it is not recommended to do so. After Xcode8 comes out, I hope everyone can get started quickly and update all staff. . This is the same as Xcode5 to Xcode6, there are changes, but you still have to learn and adapt as soon as possible!

Three, code and Api attention

After using Xcode8, some code may not compile, and I will talk about the problems I encountered.
1. The proxy method of UIWebView:
**Note to delete the nullable in front of NSError, otherwise an error will be reported.

- (void)webView:(UIWebView *)webView didFailLoadWithError:(nullable NSError *)error
{
    [self hideHud];
}

Fourth, the solution to code comments not available

This is because Apple solved the xcode ghost and blocked the plug-in.
Solution
Open the terminal and run the command: sudo /usr/libexec/xpccachectl
Then you must restart the computer to take effect

Note: Xcode8 has a built-in function to open comments, the location is here


QQ20160914-3.png

The shortcut keys are set here


QQ20160914-2.png

It seems that Xcode8 cancels the function of the third-party plug-in. For details, please refer to the Xcode8 Source Editor

5. Permissions and related settings

Note that when adding, there should be no space at the end.
We need to open the info.plist file to add the instructions for the corresponding permissions, otherwise the program will crash on iOS10.
The details are as follows:


QQ20160914-0.png

Microphone Permission: Privacy - Microphone Usage Description Allow this app to use your microphone?
Camera permissions: Privacy - Camera Usage Description Allow this app to use your camera?
Album permissions: Privacy - Photo Library Usage Description Allow this app to access your media library? Contacts permissions: Privacy - Contacts Usage Description Allow this app to access your contacts?
Bluetooth Permissions: Privacy - Bluetooth Peripheral Usage Description Allow this app to use Bluetooth?

Speech-to-text permission: Privacy - Speech Recognition Usage Description Allow this app to use speech recognition?
Calendar permissions: Privacy - Calendars Usage Description Allow this app to use calendars?

Location Permission: Privacy - Location When In Use Usage Description We need to obtain relevant data around you through your geographic location information.
Location Permission: Privacy - Location Always Usage Description We need to obtain relevant data around you through your geographic location information
. It needs to be written like this to prevent the listing from being rejected.

6. The font becomes larger, and the original frame needs to be adapted

After being reminded by some friends, I found that the width of the original 2 words in the program was 24, and now the 2 words need a width of 27 to display. .
I hope friends who have a solution, let me know in the comments, thank you

7. Push

As shown in the picture below, don't forget to open it. All push platforms, whether it is Aurora or something, must be opened in order to receive push notifications✌️


QQ20160914-4.png

Then you should be able to receive the push. In addition, Aurora Push has also launched a new version, and you can also update it.

PS. Apple has made a lot of changes to the push this time, I hope you will check it out more, and the proxy method for handling push has also changed.

// 推送的代理
[<UNUserNotificationCenterDelegate>]

iOS10 is no longer in the
[application: didReceiveRemoteNotification:]method to receive notifications. iOS10 introduces a new proxy method to receive and process various types of notifications (local or remote)

- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler { //应用在前台收到通知 NSLog(@"========%@", notification);}- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)())completionHandler { //点击通知进入应用 NSLog(@"response:%@", response);}

I will update the article later to give a detailed explanation of push.

8. Block cluttered bugs

After updating Xcode8, the newly created project will print a bunch of inexplicable and incomprehensible Logs.
Such as these

subsystem: com.apple.UIKit, category: HIDEventFiltered, enable_level: 0, persist_level: 0, default_ttl: 0, info_ttl: 0, debug_ttl: 0, generate_symptoms: 0, enable_oversize: 1,

The method of shielding is as follows:
Edit Scheme-> Run -> Arguments in Xcode8, add
OS_ACTIVITY_MODE = Disable in Environment Variables


 

If you still print the log after writing, please re-check the checkmark, you can solve it

 

Link to the original text: http://www.jianshu.com/p/9756992a35ca
The copyright belongs to the author, please contact the author for authorization, and mark "Simple Book Author".

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=326603093&siteId=291194637