Updating to Swift 4.1

Swift 4.1 is released on the 29th of March and will be shipped with Xcode 9.3. Although it’s a minor language release, it did bring some improvements.

How to get started?

First of all, Swift 4.1 is source compatible with Swift 4.0. So no need to rush! Before you start, get yourself up to date with the latest changes. Doug Gregor and Ben Cohen recently discussed many of the new features on a two-part episode of the Swift Unwrapped podcast. Check out the podcasts here: Part 1 and Part 2.

If you did not update your Swift code to Swift 4.0 yet, it might be a bigger step. Read through the migration guide first and evaluate if it’s the right time to update.

Updating existing code to Swift 4.1

Quite some features make it possible to revisit and improve your existing code. To make this easy, you can walk through this list:

  • Update your Codable code with the new strategies for converting keys during encoding and decoding by using this forum post
  • Optimise your code by using the new Code Size Optimization Mode
  • Revisit your Equatable and Hashable code. You can probably remove quite some boilerplate code as a result of this proposal:

    Developers have to write large amounts of boilerplate code to support equatability and hashability of complex types. This proposal offers a way for the compiler to automatically synthesize conformance to Equatable and Hashable to reduce this boilerplate, in a subset of scenarios where generating the correct implementation is known to be possible.

  • Read through the Conditional Conformance updates as Swift 4.1 includes the SE-0143 Conditional Conformance proposal. More info can be found in this blog post.

More info and a detailed description of this release can be found in this blog post.

Follow on Feedly