Swift. Static and Dynamic Libraries. Frameworks

Maxim Krylov
4 min readMay 20, 2021

Here is a quick introduction, along with the full articles list

There are a lot of articles that tell about libraries and frameworks in Swift. At the bottom of this page, you will find links to materials I highly recommend to get acquainted with

The goal of my work isn’t to produce one more article that tells the same as dozens before. Even more, most of them are really great!

In this article, I tried to visualize the process of compiling, linking, and simply working with libraries and frameworks. I hope this work will be a good extension of materials you can find all over the Internet and in the Apple documentation

Well, let’s get started with the types of code:

Static libraries are fully embedded into the result executable binary

Dynamic ones behave differently. The result executable binary has just references to the functions of that libraries. And the code of the functions is loaded at runtime

Let’s take a look at what Xcode and iPhone do under the hood:

And now let’s see what frameworks are:

To summarize everything above, let’s say that in iOS/macOS development, there are two types of modules:

  • library, and its synonyms like a static library, static framework
  • framework, and its synonyms like a dynamic framework

Telling about libraries or static frameworks, people assume static libraries — modules, that are fully embedded into the result executable binary

And speaking about frameworks, they refer to dynamic libraries that are wrapped by frameworks and linked to the executable binary via references to their functions

There are several helpful terminal commands that allow you to determine the type of binary and get some useful information: