WWDC 2016 Initial Impressions

Check out a developer’s initial impressions of the new announcements at WWDC 2016 so far! By Chris Wagner.

Leave a rating/review
Save for later
Share

It’s the most wonderful time of the year for Apple developers!

The first day of WWDC brought lots of new APIs and features for us to dive into, including Swift 3, SiriKit, iMessage Apps, and more.

Ever since the Platforms State of the Union I’ve been diving into the docs, and I thought it would be useful to post my first impressions of all the news, from a developer’s perspective.

Feel free to post any of your own thoughts, or anything I may have missed!

Swift 3

The change from this year that will have the biggest impact on developers is the release of Swift 3 in late 2016, since it will require us to all make some major changes to our Swift code.

However, if you’ve been following along with the Swift evolution project, this really shouldn’t be a surprise. Since Swift is open source, Apple and the community have been working extremely hard on this over the past 6 months, and everything’s been discussed publicly. Nothing new was announced today, aside from one thing: Swift 3 is conveniently packaged with Xcode 8, side-by-side with Swift 2.3.

This addresses one of my biggest complaints from last year, where we were unable to use Xcode 7 unless we also migrated our source code to Swift 2. But since Xcode 8 ships with both Swift 2.3 (which is source code compatible with Swift 2.2), you can now bring your Swift 2.2 projects over to Xcode 8 right away, and you can wait to upgrade to Swift 3 until you’re ready.

In case you haven’t been following the Swift 3 discussion, we’ll be releasing a full post on What’s New with Swift 3 tomorrow. In the meantime, I did want to mention one thing in particular that will affect all of us.

Swiftier Objective-C APIs

One of the biggest changes coming with Swift 3 is that Apple is giving a massive face-lift to its APIs to make them more “swifty”.

It’s easiest to understand this by looking at a few examples. Here’s an example of working with strings:

// Swift 2.2
let content = listItemView.text.stringByTrimmingCharactersInSet(
    NSCharacterSet.whitespaceAndNewlineCharacterSet())

// Swift 3
let content = listItemView.text.trimming(.whitespaceAndNewlines)

Note how the Swift 3 version is much more concise, and makes use of an enum.

And here’s an example of working with Core Graphics:

// Swift 2.2
let context = UIGraphicsGetCurrentContext()
CGContextMoveToPoint(context, 5, 0)
CGContextAddLineToPoint(context, 10, 10)
CGContextAddLineToPoint(context, 0, 10)
CGContextClosePath(context)

// Swift 3
let context = UIGraphicsGetCurrentContext()!
context.moveTo(x: 5, y: 0)
context.addLineTo(x: 10, y: 10)
context.addLineTo(x: 0, y: 10)
context.closePath()

Note the switch from global C functions to handy methods on the context.

And finally, here’s an example of using GCD with a much simpler API:

// Swift 2.2
let queue = dispatch_queue_create("myqueue", nil)
dispatch_async(queue) { 
  // do stuff
}

// Swift 3
let queue = DispatchQueue(label: "myqueue")
queue.async { 
  // do stuff
}

As you can see, the goal is to reduce verbosity in naming in favor of terse yet expressive code; and moving away from globally defined functions in favor of members of respective types.

The changes here are going to take some getting used to for seasoned developers, but in the long run it will make the language cleaner and more approachable to new developers. Also, Xcode 8 ships with a migration tool to convert your existing code to Swift 3, which should make things much easier.

I am really excited to see these changes because ultimately the new APIs feel much more intuitive than they do today.

Note: To learn more, check out Apple’s API Design Guidelines and Better Translation of Objective-C APIs into Swift.

Swift Playgrounds on the iPad

Ever since the release of the iPad Pro, developers have been anticipating Xcode for the iPad.

We didn’t quite get that, but we did get a step in that direction with the announcement of Swift Playgrounds for the iPad. It’s similar to the Playgrounds we already know and love, but it also has a nice custom keyboard and UI for easily creating code, and some nice built-in tutorials for beginners.

It looks to be particularly well suited for teaching people Swift as their first programming language, but I can also see it being handy for experienced developers looking to prototype some code on the go.

Xcode 8

rayroll-square

It wouldn’t be WWDC without a major update to Xcode!

Here are some of the top highlights for me so far.

Memory Debugger

One of the coolest new features for me was Xcode 8’s new memory debugger.

This is a built-in tool that lets you view the entire memory object graph of your running application, so you can quickly isolate leaks and circular references. As soon as you spot them in the graph you can select it, view that frame’s stack and jump straight to the line of code causing the issue. Simply brilliant!

Even more, the new memory debugger can automatically detect memory leaks and help you quickly diagnose the problem. The demo was beyond impressive and drew massive applause from the audience. Goodbye, retain cycles!

Interface Builder Improvements

Have you ever tried zooming out in Interface Builder, then tried to drag in a button, and realized that you couldn’t unless you were at 100% zoom level?

Well, those days are no more! Interface Builder in Xcode 8 now allows you to edit your scenes at any zoom level.

It also comes with a handy new configuration bar that allows you to easily preview your view controller sized for different devices and size classes (iPhone, iPad, etc), and identify ambiguous layout constraints before you ever build and run. This is going to be such a time saver for users of Interface Builder.

Source Code Editing

Xcode 8 improves on the source editor by autocompleting image assets in your project with a preview of the image itself, right in line with your code!

xcode8-image-literal

You achieve this by typing the name of your image and a non-optional UIImage instance is returned.

In addition, Xcode 8 can display colors right in line for literal definitions:

xcode8-color-literal

You achieve this by typing color into the editor and choosing the “Swift Color Literal” option which will bring up a color picker.

You can also create your own Source Code Editor Extensions to customize the coding experience. There is a new Xcode template to get started with, and when you’re finished you can distribute your extensions via the Mac App Store or as a Developer ID signed binary through any other medium. I am looking forward to seeing what you all develop!

Chris Wagner

Contributors

Chris Wagner

Author

Over 300 content creators. Join our team.