Apple has just released Xcode 10 at WWDC 2018. Let’s take a look at what new stuff can be found in this version of Xcode, which works alongside iOS 11.

I’ll continue update this article over time as more details become apparent.

Dark Mode

The famously rumored dark-mode is coming to Mac OS Mojave and so, Xcode 10 is going to be able to adopt this dark mode, when you have Mojave installed already that is! Naturally you can also use the dark mode with Instruments as well.

In addition, you can now start to create your own dark-mode compatible apps. You can previous how your app will look in both light and dark mode inside Interface Builder  and you can quickly switch your preview between the two settings.

Through the method of setting the preferredUserInterfaceStyle of your UIViewController to a UIUserInterfaceStyle of .light, .dark or .unspecified you can take control of whether your app will show dark-mode, overriding the system value. The default value of this property however is unspecified which results in your view controller following the system’s currently set mode of either light or dark.

We can use asset catalogs in Xcode to create “dark-variants” of our assets which show only in dark mode.

Changes inside Xcode

Refactoring

Apple has taken onboard input from open source contributors to extend the refactoring toolset in Xcode to become more useful and flexible (this is because the transformation engine is open source as part of swift.org).

Xcode 10 has a Caller / Caller Feature allowing you to find where in your app a particular method is being called from (cmd clicking on any method which gets called show this option):

A Source Control Change Bar sits on the left hand side of your code editing window highlighting lines of code which have changed since the last checkout. The style and color of the change bars indicate the nature of the changes such as: uncommitted, upstream, unpushed, or conflict. The aim of this is to be able to see in a very immediately way where changes have been made to the code, either by you or by other team members.

In the above example, using the key below we know there’s an upstream change, and a conflict.

Code Folding has been made easier in Xcode 10 as well, which is ideal when refactoring: by tapping on the code-folding ribbon to the right of the line numbers you can fold or expand any code segment (a code block surrounded by braces) in the file you are currently editing.

To turn on code folding you simply need to go to Xcode / Preferences / Text Editing and tap the checkbox next to code folding ribbon:

Multi-Curser editing  now allows you to change multiple lines simultaneously, holding ctrl+shift as you tap at different lines of code allows this to be done:

Furthermore, column editing is also possible simply by holding down the option key and dragging a box over the column you want edit or remove in your code.

Instrument Customization

“You can build your own instrument with custom visualization and data analysis.”

“Xcode includes templates so you can build instruments using the same tools that Apple uses. Your instruments can easily be shared as part of your project and installed by other team members or users of your public frameworks.”

Quicker Compilation / Speed Improvements

With Swift 4.2 you can now achieve quicker compilation times; in fact Apple apple claims that some large apps can build twice as fast using Swift 4.2 and Xcode 10 compared with Swift 4 compilation times.

Load times for large documents are claimed to be up to 2.5x faster.

Code completion has also been improved, since code completion will now provide a more focused set of results and will limit its suggested completions to those which are “high-confidence matches”with what you have typed.

Jump to Definition now provides contextual details such as file and line information on where the suggested definitions are located.

Testing Improvements

It has often been a bugbear of Xcode developers that unit test in Xcode ran very slowly compared with testing in other IDEs. To address this, Apple has apparently placed a focus on improving times for executing tests.

Code Coverage Reports enhancements allow you to generate coverage reports for individual targets in your app to make them more focused, so you know how far you have to go in add to your unit-test if you want a better percentage of code coverage.

New Testing Workflows include: allowing you to automatically include or exclude newly written tests in your test bundles. You can now also randomize the order in which your tests are executed as a method of checking for accidental decencies such as in the order a set of methods are executed.

Execution of your unit-tests in parallel can now also be done within Xcode, it achieves this by effectively cloning out your app to multiple simulators and passing different tests to each (clearly taking more advantage though this method then of multi-core processors to minimize test execution time, so of machines with loads of cores your tests could run mind-blowingly faster than before).

This also works for UI-Tests as well, allowing amazing speed improvements with something like a new Mac Pro running a whole bunch of simulators at once to test a bunch of different UI interactions in your apps.

The source control navigator “makes it easy to view each of your branches, tags, and remotes with a timeline of commits. Inspect an entry to see all affected files or double-click on a commit to see everything that changed. Common operations, such as creating and merging branches, are quickly accessible in the navigator.”

Playgrounds Improvements

“In Xcode 10, playgrounds are dramatically enhanced to work more like a traditional REPL, while making the live view even more responsive and fun to use for quick designs.”

For machine learning apple have added a new “Create ML” framework allowing you to train models directly from within playgrounds together with the model design that you could use in your app. This workflow has been optimized to be fast, and with the ability to use the same code and syntax that you use in your main Swift 4.2 programs. You can then just drag and drop your model right from your playground into your production app for use.

Source Control Improvements

XCode 10 extends the source control capabilities of XCode to include a wider range of providers, and allow for more functionality from inside the IDE.

You can now actually create an upload new ssh keys to your service accounts right inside Xcode.

For Service Integrations now also have support for Bitbucket cloud and server, as well as Gitlab.com and self-hosted Gitlab inside Xcode! Something which had frustratingly be absent in previous versions.

Furthermore, inside Xcode, the pull action now supports rebase which is implemented in the way that “Xcode offers to rebase your changes when pulling the latest version of code from your repository”.

Debugging: Usability and Performance

LLDB (has faster startup and more precise access to variables)

Downloading Debug Symbols is claimed to be up-to 5x faster than before.

In Xcode 10, enhancements have been made to memory-debugging tools like the Debug Memory Graph. These have faster loading and a new more compact layout to allow visualization of more of your apps memory structure at one time.

Energy diagnostic reports are something previously introduced, but a feature in Xcode 10, which allow you to track high energy use down linking in with stack traces to allow you to see which methods are using more than expected in your app.

Build System Improvements

As we know, the build system in Xcode has recently been changed over to one that was re-coded from the ground up in Swift, making it significantly faster. In Xcode 10 this build system will be turned on by default for all projects.

Open source projects compiled with Apple’s new Size Optimization were up-to 30% smaller binary executables as a result.

Conclusion

It looks like there are a lot of strong improvements coming through with XCode 10 and iOS 11, how many apps need to be re-coded to avoid crashes or issues with the new OS and Swift version remains to be seen.

The iOS developer community will however strongly welcome some of the much called for improvements seen in this new version.

 

Sources

A: https://developer.apple.com/xcode/

B: https://www.youtube.com/watch?v=D3e9CXbrIF8

C: https://www.whatsnewinswift.com/

D: https://developer.apple.com/videos/play/wwdc2018/102/

 3,592 total views,  1 views today

Last modified: June 9, 2018

Author

Comments

Write a Reply or Comment

Your email address will not be published.