Swift 4.1 is now officially released! It contains updates to the core language, including more support for generics, new build options, as well as minor enhancements to Swift Package Manager and Foundation. There was also significant progress made in stabilizing the ABI.
The most code-affecting (by elimination, in the case of Equatable & Hashable!) bits are the progress on the generics front:
Swift 4.1 adds more generics features to the language, furthering the goals set out in the Swift Generics Manifesto. The following generics-related proposals have been implemented in this release:
SE-0143 Conditional Conformance
SE-0157 Support recursive constraints on associated types
SE-0185 Synthesizing Equatable and Hashable conformance
SE-0187 Introduce Sequence.compactMap(_:)
SE-0188 Make Standard Library Index Types Hashable
SE-0191 Eliminate IndexDistance from Collection
For more information about progress made with conditional conformance in Swift 4.1, check out this blog post…
Do indeed check out that blog post,
The Swift 4.1 compiler brings the next phase of improvements from the roadmap for generics: conditional conformances.
This post will look at how this much-anticipated feature has been adopted in Swift’s standard library, and how it affects you and your code…
TL;DR: Things like Optionals and Arrays and Dictionaries will now be Equatable if their contents are, the way things should work!
Also, if you’d like more mapping smarts in JSONDecoder, there’s help with that:
The strategy enum allows developers to pick from common actions of converting to and from `snake_case` to the Swift-standard `camelCase`. The implementation is intentionally simple, because we want to make the rules predictable…
More discussion in Swift 4.1 improves Codable with keyDecodingStrategy
And the common nil-stripping application of flatMap is deprecated: Replacing flatMap With compactMap
If you‘re trying to hit a binary size target, this’ll help: Code Size Optimization Mode in Swift 4.1
That’s about it for things we’ve noticed of interest, but there’s another comprehensive roundup over at Chez Wenderlich in What’s New in Swift 4.1? — anything we missed here is no doubt in there!