Give your simulator superpowers

RocketSim: An Essential Developer Tool
as recommended by Apple

Updating to Swift 4.1

Stay updated with the best of Swift

Join over 20,003 Swift developers in SwiftLee Weekly for exclusive tips and updates. Don’t miss out – subscribe now:

You can always unsubscribe, no hard feelings.

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.

 
Antoine van der Lee

Written by

Antoine van der Lee

iOS Developer since 2010, former Staff iOS Engineer at WeTransfer and currently full-time Indie Developer & Founder at SwiftLee. Writing a new blog post every week related to Swift, iOS and Xcode. Regular speaker and workshop host.

Are you ready to

Turn your side projects into independence?

Learn my proven steps to transform your passion into profit.