Wow, what a week it has been. There is a lot to take in, but first, I should thank the great people that set up AltConf this year. I did not get a ticket to WWDC 2015 itself, but decided to go to AltConf this week, and I’m definitely glad I went. It was a great place to learn several new things in quick succession from other great people from the Swift and iOS programming community. It was even more awesome to be able to meet members of the community at AltConf in person. Thank you to those that helped run AltConf, and I hope those of you that went enjoyed it as well.
Swift news at WWDC 2015
Swift 2 is now in beta, with a whole lot of updates that improve many of the earlier hangups. Today is going to be a summary of just a fraction of them, which will be covered in the coming posts. Among the improvements are:
- Error Handling — Makes handling errors (or NSErrors in when interoperating with Objective-C) a lot more like exception handling is done in other languages, with “try”, “catch”, and “throw” keywords.
- Protocol Extensions — Much like how you can add extensions to classes, structs, and enums, you can now add extensions to Protocol types. The most notable example in the standard library being the CollectionType, giving common abilities to Arrays and Dictionaries.
- Early Existing — The guard statement is much like an if statement, but it ONLY contains and “else” clause. If the condition is true, it continues execution like normal. If the condition is false, then the “else” clause is run, where you should address the problem appropriately, and often exit the containing scope, such as with a “return” or a “break”. Since the entire rest of the containing scope is the guard statement’s “if true” clause, a constant assigned via optional binding in the guard statement’s conditional can be used in the guard statement’s enclosing scope.
- Improved Unit Testing Visibility Keyword — Previously, you could only perform unit tests on functions that were marked as public in your code (since public allows anything to see the functions, while internal limited it to only to sources in the same module). That is the default behavior in Swift 2 as well, HOWEVER, with the “@testable” attribute on your imports, you can now grant the Unit Testing target access functions or properties marked as “internal” as well.
- API Availability Checking — This makes it a lot easier to check in an if or guard statement whether you are on the correct platform or version to call certain APIs (such as making sure you’re on iOS 9 to use the new UIStackView). This goes along with warnings that show up when compiling, if an API called is not available int the minimum deployment target.
There are so many more additions to Swift than I should cover in this WWDC 2015 summary post, not to mention the additions to UIKit like the UIStackView I mentioned a moment ago. We’ll be covering these additions and many more in the coming posts. The updates in Swift 2 make programming in this great new language for iOS even easier.
Of course, how could I write about Swift news from WWDC 2015 without mention probably one of the most important items:
Swift will be Open-Sourced
Swift will be open-sourced by the end of the year, with a Linux port being provided as well. This means that any of us can see how Swift works under the hood, and even submit pull requests in order to add functionality that we think should be in the language. Of course it is still up to Apple (as with any source repository owner) whether to merge in those changes, but I’m sure that the cream of the crop will be.
This also means that ports to other Operating Systems can be far more easily made, with Swift’s compiler being completely open-sourced. As mentioned previously, Apple will be throwing in a Linux port themselves, but this means that those with the know-how can port it to work with many others, even Microsoft Windows. Perhaps even to web servers, instead of Go or Ruby? We shall see.
Watch News at WWDC 2015
This was the first WWDC that the Apple Watch has seen, and it got a lot of love here. Most notably, Apple officially announced watchOS 2 this week at WWDC 2015. With watchOS 2, the code for your Apple Watch Apps will run on the device itself, which (first and foremost) will improve launch time and responsiveness.
With this move, we are also granted more access to the sensors and hardware, such as the digital crown, the taptic engine, heart rate, accelerometer, and the microphone. Code running on the Watch itself can also connect to the greater internet to download information (such as the weather, or a podcast file) directly, without needing to go through the phone, if you wish.
This will allow apps a lot more capabilities that just weren’t possible in watchOS 1. We also get the ability to write our own complications to put on the user’s watch face.
iOS 9 News at WWDC 2015
There are several user facing features for iOS 9, and you can read more about at Apple’s iOS9 page. We will talk about the more developer related aspects below:
Firstly, a new capability called Slide Over is available on iPad. This allows the user to slide another app onscreen to interact with while the current app appears to be suspended, but still visible. This could be used for simple things like making a note or using a social media app.
The iPad Air 2 (and probably any iPads released afterwards) have a more powerful version just called “Split View”, which lets two apps both run onscreen simultaneously (where Slide Over only has one active, and the other onscreen, but not suspended).
These two changes are particularly important because our apps will need to handle being in different sized windows in Slide Over or Split View by using Auto Layout and Size classes.
We also are able to interact with the built in searching in iOS, allowing it to know about the content of your app. For instance, a podcast app could let the user search for one of their podcasts from the search screen, and then jump right into that section of the app to play that podcast.
Xcode News at WWDC 2015
This post is getting pretty long for a summary post, so I’ll keep this much more concise. Xcode 7, which of course can write apps in Swift 2 for iOS 9 and watchOS 2, has added a few features, particularly for testing. We now have built in User Interface testing, as well as code coverage. You can record a User Interface session (or write it yourself, if you wish), and play that back as a test, with some assertions along the way to make sure things worked as they were supposed to. The code coverage feature, lets you see which parts of your code were run by your tests, to make make it even easier to know what still needs testing in your app.
Developer Account Updates
Last, but CERTAINLY not least, were the assorted changes to developer accounts. Firstly, you no longer need a paid member ship to run apps on your own devices. You of course need one for app store distribution, but if you want to test on devices you have physical access to, you won’t need to pay for just that. This is HUGE for helping people get into developing for iOS. The simulator is great, but nothing beats actually testing on a device, and now this lowers the barrier to entry to doing so.
With the addition of watchOS as a new platform, apple has also combined all of the developer programs. This means that you no longer need to pay for a Mac OS and iOS developer account, if you submit to both app stores. Now, you get an Apple Developer account that lets you deploy to the iOS App store, as well as the Mac App store.
Now the new Apple Developer forums no longer require an account to view. This also lowers the barrier to entry for people wanting to learn from others about how to program in this ecosystem. An account is still necessary to post, but that’s no different than any other forum. This also allows (presumably) search engines to index the developer forums, making it easier for somebody looking for help on an iOS development topic to find the Apple developer forums.
Suffice it to say, there have been a LOT of changes and updates to Swift, iOS, Xcode, and even the developer accounts themselves, announced at WWDC 2015. Stay tuned for articles about many of these new features of Swift 2 and iOS 9.
I hope you found this article helpful. If you did, please don’t hesitate to share this post on Twitter or your social media of choice, every share helps. Of course, if you have any questions, don’t hesitate to contact me on the Contact Page, or on Twitter @CodingExplorer, and I’ll see what I can do. Thanks!