Swift ABI Stability and Module Stability

Deepal
2 min readApr 21, 2022

--

ABI Stability (Application Binary Interface)

  1. Swift interacts with other libraries and components using ABI
  2. When you create a function that function will be called using ABI
  3. Before swift 5.0, ABI was not stable. Each application bundles its own version of the Swift Dynamic library which means it doesn’t live on operating system instead it would be found in the application’s bundle
  4. Each app creates its own ABI and has its own Swift Dynamic library inside the app bundle
  5. The app bundle size increases as each app has its own Swift Dynamic library and ABI
  6. Swift 5.0 onwards, the Swift Dynamic library is the part of the Operating system and it will be compatible with all other version
  7. See the difference before and after 5.0 with ipa file, before 5.0 ipa file would contain framework folder which contains the Swift Dynamic library which increases the app’s bundle size
  8. Enables the compatibility at runtime

In short, from Swift 5 the app bundle size reduces as the Standard Dynamic library is part of OS

Module Stability

  1. Module stability allows us to use third party library without worrying about at which version it was compiled
  2. For the framework, if framework is compiled with swift 4 and importing project is swift 5 then it will not compile, as it is does not support module stability
  3. Available from Swift 5.1
  4. Module stability enabled swift ipa contains a folder name `.swiftmodule` which contains `.swiftinterface` and `.swiftmodule` files. These are text based representation of framework’s API
  5. To enable module stability enable `Build Library for Distribution` settings in build settings and set `Skip Install` to `NO`, after this, xcode includes the `.swiftmodule` in your bundle when you archive it and this make framework module stable
  6. Enables the compatibility at compile time

In short, from Swift 5.1 Developers can easily use third party frameworks without worrying about framework and application’s swift version compatibility.

Bramha says Krishna is God, Lord Shiva says Krishna is God, Indra says Krishna is God, Varuna says Krishna is God, Agni says Krishna is God and Krishna says Yes I am God

--

--