2 min read

The Swift team released Swift version 4.2 yesterday. Swift 4.2 comes with updates to the Swift language including generics improvement, and standard library updates. Swift 4.2 also comprises changes to the package manager.

Swift is a general-purpose and multi-paradigm programming language developed by Apple Inc. for iOS, macOS, watchOS, tvOS, and Linux. Swift is built for uses that range from systems programming to mobile and desktop apps, to scaling up to cloud services.

Let’s have a look at the key features in Swift 4.2.

Language updates

Swift 4.2 is a major language release and comprises of language changes such as Generics improvements, and Standard library updates.

Generics Improvement

Better support has been added for Generics which ultimately makes more of your code reusable.

Standard Library updates

The standard library in this latest release consists of a number of new features such as improvements to the Hashable protocol and a new unified set of randomization functions and protocols.

Other updates

Swift 4.2 has enabled the binary compatibility for future releases of Swift. Support has been added for batch mode compilation that results in faster build times. There’s a change in calling convention for retain/release cycle which helps reduce the code size and improve runtime performance.

Package Manager Updates

Swift 4.2 explores three new features namely, batch mode support, improved scheme generation logic, and automatic Xcode project generation.

With Swift 4.2, the swift targets will be now compiled using the Swift compiler’s batch mode The scheme generation logic has been improved and it generates the following schemes:

  • One scheme comprising all regular and test targets of the root package.
  • One scheme per executable target consisting of the test targets whose dependencies intersect with the dependencies of the executable target.

Swift 4.2 offers automatic Xcode project generation. The generate-xcodeproj here has a new –watch option which enables it to watch the file system and regenerate the Xcode project automatically, if needed.

For more information on this release, check out the official release notes.

Read Next

Your First Swift Program

What’s new in Vapor 3, the popular Swift based web framework

Swift’s Core Libraries

Tech writer at the Packt Hub. Dreamer, book nerd, lover of scented candles, karaoke, and Gilmore Girls.