May The 4th Be Swift You

Got your Swift 3 rewrites all done? Good, good, because now it’s time for…

What’s new in Swift 4.0

Swift 4.0 is a major new release for everyone’s favorite app development language, and introduces a variety of features that let us write simpler, safer code. You’ll be pleased to know it’s nothing as dramatic as the epic changes introduced with Swift 3.0, and indeed most changes are fully backwards-compatible with your existing Swift code. So, while you might need to make a handful of changes it shouldn’t take long.

WARNING: Swift 4 is still under active development. I’ve selected some of the most interesting and useful new features for discussion below, all of which are implemented and available to try now. Please keep in mind that more features are likely ship in the months before final release.

  • Swifty encoding and decoding…
  • Multi-line string literals…
  • Improved keypaths for key-value coding…
  • Improved dictionary functionality…
  • Strings are collections again!…
  • One-sided ranges…
  • There’s more still to come…

The first release of Xcode that ships with Swift 4 is likely to arrive in June, presumably along with iOS 11, tvOS 11, watchOS 4, and macOS Somewhere Else In California. What we’ve seen so far is already promising, particularly because it’s clear the team is working hard to make Swift 4 as additive as possible. Primarily adding new features rather than breaking or modifying existing ones should make it easier to upgrade to, and hopefully signals the start of a new stability for the language…

One feature that was postponed was ABI compatibility, which would allow developers to distribute compiled libraries – one of the few key missing features that remain in Swift today. Hopefully we’ll get it before Swift 5…

So if you want to get a jump on this year’s Grand Transition, go check that out.

And if you’re really eager:

Playground: Whatʼs new in Swift 4

I made an Xcode playground that lets you try out many of the new features coming in Swift 4. You can download it on GitHub.

The cool thing is that you can run the playground right now in Xcode 8.3; you donʼt have to wait for the first official Swift 4.0 beta, which will probably come as part of Xcode 9 at WWDC. All you need to do is install the latest Swift snapshot from swift.org (donʼt worry, itʼs easy)…

Hands-on code examples to help you learn what’s new in Swift 4: new encoding and decoding, smarter keypaths, multi-line strings, and more!

Yeah, personally I think we’ll manage to contain ourselves for that 17 more days, thanks. Handy playground to have around then though!

UPDATES:

Building Swift Projects In Source Compatibility Mode

Alex | May 18, 2017

Leave a Reply