Quantcast
Channel: Envato Tuts+ Code - Mobile Development
Viewing all articles
Browse latest Browse all 1836

What’s New in Xcode 9?

$
0
0
Final product image
What You'll Be Creating

This year’s WWDC announcements focused on the exciting new SDKs, such as ARKit, and the changes to iOS 11. However, Apple has also made significant improvements to Xcode with Xcode 9. Not to be outshone by the other announcements, the new version of Xcode is a leap forward for coders. Developers are sure to be happy!

Included in this year’s improvements:

  • updated support for Swift 4, including parallel support for Swift 4.0 and 3.2
  • super-charged speed improvements to Xcode Project Navigator and Editor, from indexing to refactoring tools
  • a completely rebuilt source code management (SCM) component, with seamless Git and GitHub integration
  • ability to run multiple concurrent simulators, as well as wirelessly debug on physical devices such as the iPhone and Apple TV
  • a new Main Thread Checker tool to ensure UIKit and AppKit thread compliance
  • improved Interface Builder rendering of UI components.

Certainly this is a very exciting list of changes, so let’s go them one by one, starting with Swift 4.

Support for Swift 4

Swift is steadily evolving year over year, and this year Xcode is supporting the latest major Swift release, Swift 4. While the latest open-source iteration isn’t as big a jump as the previous versions were, Xcode 9 has made the process even more convenient. 

For starters, Xcode 9 now supports the ability to compile both Swift 4.0 and Swift 3.2 targets simultaneously, meaning that as a developer, you can choose to migrate your project gradually rather than all at once, and you can have your project targets written in either the latest or previous language version.

Picking a Swift language version

Xcode 9's compiler understands both versions, and through the Xcode Migration Assistant, will now ask users to cherry-pick which targets to migrate to version 4.0. 

In fact, Xcode 9 evaluates your code and provides insights into your project modernization compliance status and best practices, through the Editor > Validate menu option. 

Selecting targets to convert

Project Navigator and Editor Improvements

Next up, Xcode 9 gets some needed improvements to the IDE itself—in particular to the Project Navigator and Source Editor components, starting with a faster indexing engine that supercharges your ability to search and returns results quicker. 

Developers can search a large code base and get results instantly, since the indexing engine now also indexes files as they are compiled, whereas previously files in a compilation state were not subject to indexing. This gives developers the ability to quickly jump between and search files from linked projects and libraries seamlessly, a welcome benefit, especially when you work with CocoaPods and multi-project workspaces. 

The Editor itself has also been rebuilt, enabling—as Apple says—a “fast structure-based editor that lets you intelligently highlight and navigate your code”. What this means is a new highlighting engine that recognizes logically grouped blocks better, and that gives you smart tools for navigating between related parts of your codebase.

Xcodes new intelligent highlighting engine

Refactoring

In addition to allowing developers to navigate easily from class to class, or from method to method, Xcode also provides an all-new refactoring feature. The refactoring tool provides a modal editor pane to compare all possible changes as you extract and refactor Swift methods. This makes refactoring easy, even between Swift and Objective-C methods. 

Refactoring preview

You can now update symbols, modify getters and setters, synthesize iVars, and auto-fill mandatory protocol methods for conformance, all with a single click. 

Markdown Editing

Other minor improvements include native support for Markdown files (rendered with the Markdown stylings) in the editor. This improvement makes sense considering Xcode’s deeper integration with GitHub, and it's helpful to be able to access README.md files more visually within the editor. 

Markdown editor

Swift Playgrounds

Xcode 9 also provides new iOS Playground templates that you can actually test out not only in Xcode but also on Swift Playgrounds for iPad!

Swift playgrounds

Other Small Editor Improvements

Also, it's a small improvement, but the editor now lets users increase or decrease the editor font size using the macOS-conforming or shortcuts. 

Font size shortcuts

Another small improvement is with creating, renaming and deleting groups in the Project Navigator. Making changes to a group will now be reflected in the associated folder, ensuring naming consistency and eliminating an annoyance many developers had with how Xcode works with file system folders. 

Finally, improvements to Xcode’s Asset Catalog add support for the new HEIF image open standard that is part of iOS 11.

Source Control Management Improvements 

One of the most notable improvements to Xcode has been with the integrated source control management, which until now had been neglected. In place of the previous semi-baked SCM that never really felt part of Xcode, Xcode 9 now includes a completely revamped SCM integration.

SCM integration

From a new SCM navigator that is more seamlessly integrated, you also get more powerful ways of working with branches and tags. Not only that, but Xcode now features deep integration with GitHub that lets you manage your account directly from Xcode preferences, create GitHub repositories with a single click, and browse public repos from within the editor. 

For a closer look at new SCM features in Xcode 9, check out our post What’s New with Git Support in Xcode 9.

Debugging & Simulator Improvements

Not to be left behind, Debugging got a lot of attention in Xcode 9 as well. We'll start by looking into what’s new in Xcode Simulator.

Xcode Simulator

Previously, when launching Xcode Simulator, you could only launch one Simulator at a time. So, if you had to test on multiple device types, you would have to run each in turn. This made testing slower, whether for manual or automated testing.

This has changed in Xcode 9. Developers can for the first time run multiple Simulators concurrently, with automated testing tools now being able to run tests in parallel. 

Running multiple Simulators

There are a few other minor but useful tweaks to Simulator that Apple has introduced. One is that you can hold down the Option key to close the Simulator window but yet keep it running in the background. You can also start Simulator from the command line, which is useful for automated testing and delivery tools. 

Developers can also record videos of Simulators, in addition to taking screenshots, which is useful for App Store publishing. 

Last but not least, developers graduating from Simulator to testing on real devices no longer need to plug in their devices physically. Apple now lets developers cut the cord and debug iOS and Apple TV devices wirelessly, with a feature called Network Debugging.

Main Thread Checker

A new standalone debug utility Apple has introduced together with Xcode 9, Main Thread Checker is able to detect non-compliant usage of prominent SDKs such as AppKit and UIKit from a background thread. For instance, developers could be using UITableView actions in the background thread, which could result in strange visual effects and faulty updates. The Main Thread Checker is enabled by default and is configurable via the Scheme Editor. 

Built-in Xcode Server

Xcode 9 now has Xcode Server bots built in and standard, eliminating the need for developers to have an installation of macOS Server. This means developers can run Xcode Server bots on any machine and take advantage of continuous integration best practices. 

Interface Builder Improvements

Developers have been seeing gradual changes and improvements to Interface Builder (IB) over the years, with ongoing improvements to the rendering of screens. Xcode 9 continues to refine IB by rendering UI components on the canvas more accurately. Improved components include Navigation, Tab, and the Toolbars. 

Another new feature is that Xcode and IB will now warn developers when view constraints could potentially cause localization problems. For example, you will be alerted when a change to a view could cause words in another language, such as German, to be truncated or clipped. This is certainly going to save a lot of time for developers who support multiple languages. 

Speaking of layouts, Interface Builder now also supports Auto Layout safe-area guides, which are hints that help developers arrange UI elements. This deprecates the top and bottom layout guides in previous versions of Xcode.

Conclusion

The latest installment of Xcode provides a plethora of new features that will improve developer productivity. In tandem with the announcement of Swift 4, Xcode makes migration from Swift 3.2 to the latest version a lot more palatable, thanks to its support for gradual migration. Xcode has also received timely and noticeable speed improvements to search indexing and a completely rebuilt editor which is more contextually aware, with new support for refactoring. 

SCM has now been made a first-class citizen, meaning developers no longer have to toggle between Xcode and a third-party SCM editor for their git-management needs. The simulator has benefited from some of the most notable improvements, with the ability to run multiple concurrent Simulators to test across multiple devices more expeditiously, as well as the convenience of being able to cut the cord and debug on physical devices wirelessly. 

Whereas iOS 11 has invigorated the development community thanks to its exciting new SDK features, Xcode 9 provides the perfect development vehicle for delivering innovation to their users. Stay tuned for some hands-on tutorials about using the new iOS SDKs. And check out some of our other posts on iOS app development!

2017-10-09T15:00:00.000Z2017-10-09T15:00:00.000ZDoron Katz

Viewing all articles
Browse latest Browse all 1836

Trending Articles