What’s new in Swift ABI Stability

At runtime, Swift program binaries interact with other libraries and components through an Application binary Interface (ABI). Like an API, where programs interact with each other, ABI is an abstraction for binaries and frameworks.

ABI is Application Binary Interface, or the specification to which independently compiled binary entities must conform to be linked together and executed. These binary entities must agree on many low level details: how to call functions, how their data is represented in memory, and even where their metadata is and how to access it.

Apple Swift blog

While believe it or not, most of us have crossed paths with binary interface stability but what does it actually mean for developers?

Did it ever happen what you downloaded a some Swift code from GitHub and when you tried building it with Xcode, the compilation failed because it has a different Swift Version ?

Or you had to perform swift migration  to the latest Swift just to support your old code on new Xcode version

 Or when you were working on the project and accidentally your Xcode got updated. Now the project wouldn’t compile with the latest Xcode forcing you to go through the Swift migration to support the latest changes.

 Well if you had been in any above situations, then you have to blame it to the Swift ABI which was created for every version. Until Swift 5.0, Swift was not ABI stable and thus every compiler binary had to be shipped with its own version of Swift Dynamic library.

Lets say when you had iOS 13 on your device and it was running apps built on different swift versions like 4.2, 4.0, 3.0,  Every app bundle had a copy of dylib which will be loaded by OS in runtime.

Benefits for Developers?

1. Reduced bundle size

This means that apps deployed with upcoming os versions will no longer have to embed the Swift standard  libraries  and runtime in the app bundle, thus reducing its size. They will be shipped with OS like the Objective-C.

2. Language Stability

No future changes: Once interface is locked down, future compilers can produce builds conforming to the stable ABI only and would persist for future releases.

3. Compiler compatibility

No More Swift migrations. Yay! No matter on which swift version you wrote your code, it can run on any future Xcode versions. When you update to a new swift version, no need to update all the pods.

References:

https://swift.org/blog/abi-stability-and-more/

One Reply to “What’s new in Swift ABI Stability”

  1. It is really a nice and useful piece of information. I am glad that you simply shared this useful information with us. Caren Titus Blaise

Leave a Reply

Your email address will not be published. Required fields are marked *