Swift. Static and Dynamic Libraries. Frameworks

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:

--

--

--

Software Developer

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

iOS to Android App Conversion: Tips, Major Challenges, & Development Cost

Blur Detection via GPU-Accelerated Metal Performance Shaders on iOS

What’s new in Swift 5

Swift vs Python: Where Does It Lead in 2020?

SwiftUI note

.Net 5 Custom Output Formatter

How to backup data in React Native

How to style your app in SwiftUI

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Maxim Krylov

Maxim Krylov

Software Developer

More from Medium

.NET Core API Gateway Ocelot — Logging HTTP Requests & Response

How to implement memory records tool based on MallocStackLogging

Stable Dependencies Principle (SDP)

Usage of HMS Kits in Travel and Transport Applications