Monday, April 15, 2019 [Tweets] [Favorites]

Library Evolution for Stable Swift ABIs

Ben Cohen:

One of Swift’s goals is to be a good language for libraries with binary compatibility concerns, such as those shipped as part of Apple’s OSs. This includes giving library authors the flexibility to add to their public interface, and to change implementation details, without breaking binary compatibility. At the same time, it’s important that library authors be able to opt out of this flexibility in favor of performance.

This proposal introduces:

  • a “library evolution” build mode for libraries that are declaring ABI stability, which preserves the ability to make certain changes to types without breaking the library’s ABI; and
  • an attribute for such libraries to opt out of this flexibility on a per-type basis, allowing certain compile-time optimizations.

The mechanisms for this are already in place, and were used to stabilize the ABI of the standard library. This proposal makes them features for use by any 3rd-party library that wishes to declare itself ABI stable.

Greg Parker:

This feature is one of the reasons that Apple created Swift instead of adopting an existing language. We needed at least as much capability to evolve libraries as Objective-C provided.

Previously: Swift ABI Stability and More.

Comments

Stay up-to-date by subscribing to the Comments RSS Feed for this post.

Leave a Comment