New features and pits brought by Xcode8

Source: Internet
Author: User

Xcode8 new Features

Interface Builder

With the IPhone6 and 6P coming out of the 14, the iphone's screen size is becoming more and more, and screen fitting is a problem that needs to be solved in the future, not necessarily the iphone size of Apple.

In the same year IPhone6 and 6P were released, Apple launched the Xcode6 in the original auto layout based on the addition of the size classes new features, through this new feature can use a xib or SB file, Adapt to different screens and two devices for iphone and ipad.

In Xcode8, Apple has launched a more powerful preview of the visual editing tools to preview the current Xib or SB display in different screen sizes without running the app. (This feature I remember before Xcode has, just hidden deeper, Apple now to get outside)

Select a xib file to go in, click the red box below the location, will appear from 3.5 inch-5.5 inch a series of screen size options. Switch between different screen displays by clicking on different screen sizes directly, as well as the screen options. On the ipad you can also choose whether to split the screen, the function is very powerful.

There is a vary for traits option on the right, click this option to display all the optional screen styles at the same time, the function is the same as the picture above, but the display looks more.

Also, the newly created Xib control size is no longer the 600*600 square, but the default is a 6s rectangular xib file that looks much more comfortable.

Changes to general in target

Before Xcode8, you need to set up your own certificate and profile. If you set an error, you can also fix the error by clicking Fix Issue. But the problem here is that the fix issue option is not so easy to use, and sometimes the settings are correct here also prompt for fix issue.

Perhaps Apple is also aware of the problem, in Xcode8 can be automatically manage signing option, let Apple for us to manage certificates and configuration files, settings are also done by Apple. To create a new project in Xcode8, this option is checked by default.

As you can see from the image above, Apple automatically manages the certificates and configuration files for us. And in the previous project, if you want to set the app name displayed on the phone after installation, you also need to change the Display name field to the Info.plist file, and now you can modify it directly in general, this modification and info.plist are synchronous.

But what if I want to manage my certificates and profiles myself? Just remove the Automatically manage signing option.

If you manually set up the certificates and profiles in build settings, you can see that the Provisioning Profile option has been marked as deprecated, which means that Apple does not recommend manual settings.

Xcode Plugin

After upgrading Xcode8, it is found that all third-party plugins in the Xcode8 are invalidated, and even the plugin options for the previous menu bar do not exist. Many iOS developers have been using Alcatraz to manage plugins, and now Alcatraz is not available. But Xcode8 itself has also upgraded the compiler, adding some of the better plug-in features to Xcode, such as single-row highlighting.

We support the development of plug-in projects in Xcode8 and provide us with a plugin template that can be uploaded to the App Store for download. One reason for Apple to do this is because Xcode and plugins are running in the same process, so the crash of the plugin will also cause Xcode to crash. Apple now takes the plug-in as a separate application, running separate processes without any other impact on Xcode.

Runtime issues

During development, the compiler can discover and report yellow or red warnings because of syntax or obvious code errors, such as retain Cycle. But some of the errors caused by the code logic, the compiler is not able to find. For example, the following code, because the problem of code logic causes two arrays to reference each other, can not be freed.

Array Circular Reference

This can be done through the Xcode8 provided by the runtime issues new features, to find the operation of the problem occurred in the process, and graph to visualize the problem to the developer.

Debug Memory Graph

The new Debug view hierarchy feature in Xcode6 allows you to debug the view level of the current app and find UI-related bugs very handy. In Xcode8, Apple provides the developer with the Debug Memory graph feature, which allows you to select an object directly to view its associated memory relationship.

Debug memory graph and runtime issues can be used in conjunction, after the completion of the analysis of the relationship between the memories by debug, click Runtime Issues to see the memory problems that have been discovered.

Swift 3

Xcode8 brings a new version of Swift3, and the new version of Swift changes significantly if the older Swift project compiles on Xcode8 may fail. In this respect, Apple has provided the developer with the swift Migration Tool, which I heard is not very useful (I didn't use the tool).

If you do not want to migrate to Swift3 immediately, you can set it up in the builder settings and select Use Legacy Swift Language version to Yes to continue using the old version of Swift2.3.

Other updates

    1. Xcode new Font, SF Mono regular font. I prefer this font after I update Xcode, and it looks very neat code.

    2. The edited line is highlighted. Before Xcode has a plug-in is this feature, Xcode8 the highlight function in the integrated, easy to use.

    3. The latest version of the API documentation, the presentation style has changed a lot.

    4. More convenient to generate documents (that is, the vvdocumenter written by meow), you can place the cursor on the method in Xcode8, and create a document comment with the OPTION + COMMAND +/shortcut key.

Xcode8 adaptation

Xib and Storeboard adaptation

Before Xcode8, create a xib or SB file, which is a 600*600 block xib file. After Xcode8, the Xib file that you create defaults to the size of the 6s size.

But Xcode8 open the old project before the Xib or SB file, will pop up the following box, this time the general direct selection of choose device can be.

However, there is a problem if Xcode8 opens the Xib file and selects choose Device. Other Xcode8 The following version of the compiler will no longer be able to open this file, the following error will be reported:

The document "Viewcontroller.xib" requires Xcode 8.0 or later. This version does is not a support documents saved in the Xcode 8 format. Open This document with Xcode 8.0 or later.

There are two ways to solve this problem:

    • Your colleague also upgraded the Xcode8, the more recommended this way, should meet the change.

    • Right-click Xib or SB file, Open as, Source Code to delete the following line of fields in the XML file.

<code>

<capability name="Documents saved in the Xcode 8 format" mintoolsversion="8.0" />

</Code>

Compile error

After you upgrade Xcode, Xcode8 is incompatible with some of the previous modifiers and statements, resulting in some compilation errors. This kind of error causes a lot of reasons, here are roughly listed, you still based on the situation you encounter to make changes.

    1. Some of the previous generic related modifiers, such as nullable, will be error-sensitive.

    2. Caanimation and its subclasses, after setting the agent properties, you must follow the agent in @interface (), otherwise error, and so on.

Permissions adaptation

This should be a iOS10 system adaptation category, these two are in the recent, so it is directly and Xcode8 adaptation together write.

After iOS10, you need to add a new field in Info.plist to get permissions, otherwise running on IOS10 will cause a crash. Here are some of the frequently used fields, if there is a lack of trouble for you to add to the comments section.

KEY Permissions
Privacy–camera Usage Description Camera
Privacy–microphone Usage Description Microphone
Privacy–photo Library Usage Description Album
Privacy–contacts Usage Description Contacts
Privacy–bluetooth Peripheral Usage Description Bluetooth
Privacy–location when on use Usage Description Positioning
Privacy–location always Usage Description Background positioning
Privacy–calendars Usage Description Calendar

Reference: Developer.apple

Https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html

Push Notifications

Apple's push has been a big update since iOS8 and IOS9, and the push is getting stronger. After iOS10 Apple launched the Usernotifications framework, you can better control the push notification through the framework, you can update, modify the lock screen page push message, you can add pictures and other functions.

However, after packaging with Xcode8 and not modifying the code, you will find that the Apple sent an email after packaging. This message probably means that if you need to use push notifications, you'll need to make changes to your code, or you won't be able to use push notifications.

This is because after the Xcode8, if you need to use the Push notifications function, you need to check the capabilities-to-push notifications to Yes, or remote push will be a problem, And will receive this e-mail from Apple.

Delete System Log

After upgrading the Xcode8, during debugging and running, it was found that the console had printed a lot of the logs that were not known to the system, and that the logs were printed, and the developer had no problem. But so many log to look at the more chaotic, how to block out?

Subsystem:com.apple.UIKit, category:hideventfiltered, enable_level:0, persist_level:0, default_ttl:0, info_ttl:0, de bug_ttl:0, generate_symptoms:0, Enable_oversize:1, Privacy_setting:2, enable_private_data:0

In arguments, Run, Target, Edit Scheme, add the Os_activity_mode field and set it to disable.

Os_activity_mode

By the way, these two days when the log option is set, it is found that you can print out the duration of the app load by setting parameters in arguments, including the overall load duration, dynamic library load duration, and so on.

Add the Dyld_print_statistics field to environment variables and set it to Yes, and the load duration will be printed in the console.

Awakefromnib Alarm Report

Old project in Xcode8, some rewrite awakefromnib method of place, will report the following error. This is because there is no call super method caused, fortunately I usually call Super, my code is not a problem.

Method possibly missing a [super awakefromnib] Call

New features and pits brought by Xcode8

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.