2 min read

Version 5 of Apple’s Swift language, used for iOS and MacOS application development, will release early next year. The main focus of this release will be an ABI (application binary interface) stability in the standard Swift library, in addition to Standard Library Improvements, Foundation Improvements and Syntactic Additions.

ABI (application binary interface) features in Swift 5.0

ABI defines how to call a function, how data is represented in memory, where metadata is and how to access it. The current version of Swift is not ABI stable, so every binary (App), bundles its own version of the Swift Dynamic Library. For instance, if App1 is using Swift 3.0, it bundles Swift 3.0 Dynamic Library (containing the 3.0 ABI) inside. And if App2 is using Swift 3.2, it bundles Swift 3.2 and it’s 3.2 ABI. Here Swift doesn’t live on the iOS Operating System, it lives within each App.

The ABI in Swift 5.0 will enable future compiler versions to produce binaries that conform to the stable ABI. A stable ABI tends to persist for the rest of the platform’s lifetime due to ever-increasing mutual dependencies. If Swift becomes ABI Stable, its ABI will be compatible with every version of Swift. For example, if App1 is using Swift 5.0, but App2 is using Swift 5.3, both will be consuming the Swift ABI embedded in the Operating System.

The ABI feature was originally intended for Swift 4 release. Carryover goals from Swift 4 that are required for implementing the ABI in Swift 5 include:


  • Generics features for the standard library. This includes conditional conformances for generic types and recursive protocol types and lifting restrictions on associated types in protocols
  • API resilience, which will allow public APIs for a library to evolve
  • A memory ownership model

Besides ABI stability, expect these improvements in Swift 5:

#1 String ergonomics

Processing of the string type is expected to get better as users will have the ability to create raw strings, distinguish between enums that are fixed and enums that might change in the future,  and check whether one number is a multiple of another by using isMultiple(of:)

#2 Groundwork for a new concurrency model

Swift 5 will focus on designing language capabilities for building and using asynchronous APIs and dealing with problems created by callback-heavy code.

#3 Targeted improvements to the Foundation API

The Cocoa SDK- which was originally designed for Objective-C, can work seamlessly with Swift.

To try out Swift 5.0 ahead of its release early next year, download the latest Swift trunk development snapshot, activate it inside your current Xcode version,  and then head over to Xcode Playground for examples you can edit.

Read in depth about the new features to be implemented in Swift 5.0 at HackingwithSwift.

Read Next

Swift 4.2 releases with language, library and package manager updates!

Apple bans Facebook’s VPN app from the App Store for violating its data collection rules

iPhone XS and Apple Watch details leaked hours before product launch

 


Subscribe to the weekly Packt Hub newsletter. We'll send you the results of our AI Now Survey, featuring data and insights from across the tech landscape.