The new Swift is officially released and contains updates to the core language. It comes with more support in the form of general programming features and capabilities. It also comes with a series of minor lifts to Swift Package Manager and Foundation. Adding to that significantly are the changes done in stabilizing the ABI.
Let’s pick it one by one. The Swift-4.1-branch comes with tweaks and changes that will be continuously upgraded and updated with time.
The important dates include, October 18,2017, that is marked as a date for Initial Branching: Here, the Swift 4.1 Branch had been cut from the master branch to be released as a separate version entity. The updates were done every two weeks approximately. Final Branching was done on December 4, 2017.
After this date the process entered ‘bake’ period, where only critical changes were planned to be done. As announced, Swift 4.1 is released before the mid of the year 2018.
Let’s find out what all updates it comes with:
Compiler Updates
- Swift 4.1 is a minor language release.
- It is compatible with Swift 4.0 in terms of source.
- The updates on the compiler are made through the Swift Evolution process.
Language Improvements
The latest Swift, adds more generic features to the language to offer more value in reference to the baseline development needs, adding to the goals of Swift Generics Manifesto. Here are the implementations from the 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
Build Improvements
This allows you to have more number of smarter options to configure your builds, which includes a new code size optimization help and easy ways to specify which performance environment and platform support you prefer to go with.
Code Size Optimization Mode:
Now with this update you can optimize your codes to reduce their size. The best part is you can do this discreetly focusing on a particular part or cluster of code. This incredibly saves you on time.
Build Import Test:
By Import Test you are able to find out if a module or code group is importable or not. With this, swift developers are able to test different modules for their importability, putting the canImport() platform condition. The results are returned in the form of True or False and are basically based on the fact that whether the name of a module is present on all the platforms or not.
Also read: Swift vs Objective C: 5 Benefits of Swift Development
Target Environment Condition:
With the Target Environment Condition response status, you get to know if the code is compiled for a simulator. In case, it is already complied it will return ‘true’ value otherwise it will return ‘false’ value.
Foundation:
Now you have more helpful JSONEncoder and JSONDecoder classes that allow you to have new options and tactics for converting keys at the time of encoding and decoding.
ABI Stability
There are a number of under-the-hood features in Swift 4.1 that are necessarily done to make the upcoming versions more stabilized with ABI. Here’s the list:
- Now developers can access word size field for reference counting directly from the native object header.
- The witness table can be now referred to review the power and efficiency of interaction with enum discriminator.
- Every runtime function is audited for desirability and behavior.
- The layout of existential type metadata and protocol descriptors can be now chosen as per wish.
- Canonicalization can be now defined for generic and protocol requirements to best manage order-agnostic mangling.
- The most apt constraints can be now enforced on collections and sequences.
- Conditional conformance allows you to collapse different collection wrappers.
To have more information on the progress related to ABI Stability
Package Manager Enhancements
Swift Package Manager gets a couple of performance hikes in Swift 4.1. You can now see it correctly resolving package graph dependences with different URL schemes, like ssh and http. With this you can see a clear enhancement in performance for package graphs as you work with the new Swift Package Manager.
Migrating to Swift 4.1
The first thing that makes it easy to migrate to Swift 4.1 is the fact that it is compatible with Swift 4.0. So, if you want to move to Swift 4.1 from earlier releases, you can use the code migrator offered by Apple’s Xcode 9.3 which will automatically handle the source changes and help you with smooth and easy migration. If you need any help, there’s a migration guide to help you go with the process easily.
Documentation
You can go to Swift.org to have an access to the updated version of The Swift Programming Language for Swift 4.1 or you can even get to have it on Apple’s iBooks Store. Both will allow you to get it for free.
Platforms
The platforms it is built on are Linux (Ubuntu 14.04, Ubuntu 16.04 and Ubuntu 16.10). Here’s the link to download.