© 2017-2019 Hoang Nguyen
July 05, 2019 • ☕️ 3 min read
The Swift 5 release will provide ABI stability for the Swift Standard Library. ABI stability enables OS vendors to embed a Swift Standard Library and runtime in the OS that is compatible with applications built with Swift 5 or later.
Don’t confuse with API which consists of data types, structures, constants, functions that you can use in your code to access the functionality of that external component. Whereas the ABI defines the structures and methods that your compiled application will use to access the compiled external library only on a lower level.
ABI (Application Binary Interface) is the specification to which independently compiled binary entities must conform to: how to call functions, how their data is represented in memory, where their metadata is and how to access it and how an application should make system calls to the operating system.
ABI Stability means locking down the ABI to the point that future compiler versions can produce binaries conforming to the stable ABI. It enables binary compatibility between applications and libraries compiled with different Swift versions.
Before Swift 5, application built with a Swift dynamic library is going to be embedded to that bundle, in order to support your specific Swift version. This leads to bigger app sizes, and version incompatibility issues.
ABI stability is about mixing versions of Swift at run time. Swift 5 reached an important milestone when supporting stable ABI. Here are some benefits it brings to the maturity of language itself and the ultimate benefit to the Swift ecosystem:
What follows is a breakdown of the different kinds of components in Swift ABI and what needs to be specified.
The challenges to maintain binary compatibility when you’re shipping frameworks in binary form: