October 8, 2019

Swift 5.1 offers module stability for binary frameworks

Swift 5.1, an upgrade to Apple’s general-purpose language built as a replacement for C-based languages, introduces module stability. Module stability allows Swift developers to create binary frameworks that will work with future releases of the language.

Swift 5.1 introduces a new text-based module interface file that describes the API of a binary framework, allowing for compilation of Swift code using different compiler versions. Swift 5.1 also includes property wrappers that introduce a general purpose syntax for defining custom access patterns for property values including thread-specific storage, atomic operations, delayed initializers, and copy-on-write behavior.

Other new capabilities and improvements in Swift 5.1 include:

  • Support for a library evolution build mode, which allows developers to make certain changes to types without breaking the library’s ABI. Developers can opt out of this feature on a per-type basis.
  • Updates to the standard library including support for handling and updating diffs on collections and appropriate types, greater flexibility for accessing an array, and more APIs for working with Strings. API improvements were made for working with SIMD types including support for extending vectors. The standard library also adds an identifiable protocol for entities requiring unique identifiers.
  • The return keyword is no longer needed for single expression functions or getters.
  • Opaque result types enable the use of a generic type to support different types conforming to the same protocol or to hide implementation details in APIs.
  • Self can be used for value types and classes.
  • The compiler now synthesizes default values for properties with default initializers.

October 8, 2019