Apple has upgraded programming experience for its platforms such as iOS, macOS and watchOS with the release of Swift 4. The new Swift language version is largely pronounced as a major language release.
First in the series of improvements over the last year’s Swift version is new compatibility modes that help you use the new compiler without modifying your existing code. While Swift 3.2 accepts sources from the Swift 3.x compilers and doesn’t include updates to previous APIs, the Swift 4.0 mode has all the latest API changes to give a fresh feel to users.
“One advantage of these language modes is that you can start using the new Swift compiler and migrate fully to Swift 4 at your own pace, taking advantage of new Swift 4 features, one module at a time,” said Swift project lead Ted Kremenek.
In addition to the dual-mode support, Swift 4.0 has new language changes and updates that come from the Swift Evolution process. The first through this process is the easier use of String implement that includes support for creating, using and managing substrings. The new Swift also has improvements for creating, using and managing Collection types and support for archival of struct and enum types as well as a type-safe serialisation for external formats like JSON and plist.
Package manager updates come preloaded
Apple’s development team has brought new workflow features and a complete API to Swift 4 to enhance its package manager. There are improvements to create multiple packages way before tagging a first official release. Likewise, Swift developers have formalised package products to help you limit packages that will be available to your clients.
There is a new Package API that makes packages capable of specifying new settings and enables more control for package authors. The API itself is also cleaned to support new and older package versions.
Swift 4.0 comes as a part of Xcode 9 to help you build your apps for Apple ecosystem. In case you want to use the new Swift language version for a Linux platform, you can download its official binary that is currently available for Ubuntu 16.10, 16.04 and 14.04.