Top 10 things you need to know from WWDC 2015 as an iOS developer

or: How Xcode 7, Swift 2.0, and iOS 9 can help you build better iOS apps

If you don’t have time to watch the all the WWDC 2015 videos to find out what’s happening with Xcode 7, Swift 2.0, and iOS 9, read on for a quick summary of what you – as an iOS developer – need to know from WWDC this year.

If you do have time to watch a few videos, I’d recommend these:
Platforms State of the Union
What’s New in Swift
Cocoa Touch Best Practices

But assuming you’re busy and can’t spend hours watching videos… Below are some of the cool new things Apple announced that you can use to build better apps as you’re developing for iOS.

Xcode 7

1. Install apps on device easily with just an Apple ID

From Apple:

Xcode 7 and Swift now make it easier for everyone to build apps and run them directly on their Apple devices. Simply sign in with your Apple ID, and turn your idea into an app that you can touch on your iPad, iPhone, or Apple Watch.

This sounds amazing. I’m always struggling with provisioning profiles and code signing and all that stuff just to get my app running on my iPhone. Hopefully Xcode 7 lives up to its promise so we can more easily build and run apps on device.

2. Group views together with stack views in Interface Builder and have constraints added automatically

The new stack views in Interface Builder allow you to group views together so constraints can be automatically added, meaning less layout code for you. From the Platforms State of the Union talk, it looks a bit like a layout manager that allows you to stack views vertically or horizontally. It certainly looks promising, and I’m hopeful that this makes it easier to lay out views.

3. View and debug crash reports right inside of Xcode

Crashes from your App Store and TestFlight users now show up right inside of Xcode for you, and you can jump directly to the line that’s causing the crash. If you’re using or considering a crash reporting solution like Crashlytics or HockeyApp, you might want to try out Xcode’s new crash reporting tools first to see if it provides what you need. Maybe – just maybe – you’ll be able to get away with using the built-in tools instead of having to add yet another framework to your app. (Personally, I’ve never been a fan of the OS X menubar app you need to install to get Crashlytics to work.)

4. See what code is tested by your unit tests with code coverage

Xcode 7 improves unit testing with code coverage reports. Finally. When I was doing Java development in 2008, we used a code coverage tool to show us how much of our production code was tested, and it had plugins for our IDE and CI server. That was 7 years ago. It’s 2015, and Apple finally has a comparable code coverage tool built in to Xcode. I’m hopeful that it’ll help me to write better tests that cover more of the production code base.

Swift 2.0

One of the biggest features of Xcode 7 is Swift 2.0. I’m super excited for it, and I think it’s awesome that Apple will be open-sourcing it later this year. Here are some of the new things you’ll be able to do with it:

5. Handle errors with try, catch, and throws

Up to now, my approach has been to return a Result type from methods that may succeed or fail. The caller can then inspect the Result and see whether it was a Success or Failure and then do something with it. It looks to me like this will no longer be necessary with Swift 2.0 – instead, we’ll be throwing and catching errors with try, catch, and throws, similar to the way we handle errors in other languages.

Here’s some sample code from Apple’s Swift site:

func loadData() throws { }

func test() {
    do {
        try loadData()
    } catch {
        print(error)
    }
}

6. Get compiler errors when using APIs that are too new for the target OS

Finally. When you try to use an API that’s not available on the OS version you’re targeting, you’ll get a compiler error telling you the API is unavailable. I don’t even want to think about how many times I shipped an app in Objective-C that crashed for my users because I used an API that was unavailable on the version of iOS they were running. I’m glad Swift 2.0 will address this problem with a compiler error. And if you want to use a new API when your app is running on a new version of the OS, you can use the new built-in availability checking that allows you to perform those checks much more safely.

7. Use pattern matching in if clauses and for loops

Now if statements and for loops get to use pattern matching just like switch statements. I’m sure this will come in handy.

iOS 9

This year’s release of iOS is mostly focused on stability and maintenance. There are a few new features you may want to develop for, like multitasking on iPad, App Search, and App Thinning. Here’s what you can do with iOS 9:

8. Get your app ready for multitasking on iPad

In iOS 9, users can multitask on iPad in three different ways: Slide Over, Split View, and Picture in Picture. (You can see each on Apple’s iOS 9 page.) To enable your app to handle multitasking, you’ll want to use size classes in Interface Builder. It looks like this should be a fairly simple feature to support if you’re already using size classes and have a layout for compact width.

9. Let users search for information in your app with Spotlight

Now you can allow users to find information inside your app when they search with Spotlight. If your app is content heavy and/or already has search functionality inside the app, you’ll probably want to use Core Spotlight to allow iOS to show your users results from your app whenever they use Spotlight to search.

10. Give your users smaller downloads with App Thinning

If you have an app that uses lots of space on disk, you’ll probably want to look at App Thinning so users can download your app faster. Then, when they need additional content, it can be downloaded on-demand. This reduces the size of the initial download, leading to faster app downloads. Additionally, on-demand resources are automatically deleted when they’re no longer needed, freeing up disk space for your users.

And guess how much Apple is talking about Objective-C?

On the WWDC schedule, I count seven sessions with Swift in the title, and only one with Objective-C. Furthermore, that session is titled “Swift and Objective-C Interoperability,” so it actually sounds like it’s more about Swift than Objective-C. On top of that, there are eight Swift labs, and none for Objective-C, making for a total of 15 Swift-focused sessions and labs, and just one on Objective-C.

It’s clear to me that Swift is the path forward with iOS (and OS X). Apple is putting all their focus on it at WWDC, and they seem to be putting a lot of focus on it behind the scenes, too, with all the advancements in Swift 2.0 and very little in Objective-C. And in fact, most of the Objective-C improvements are just to support Swift better. If you’re still doing Objective-C, this seems like a good time to start using Swift. The writing is on the wall.