Framework Must Be Dynamic?

billibala
The Startup
Published in
1 min readFeb 1, 2021

--

No.

Framework does not need to be linked statically.

To use static framework in your app, use a popular package/dependency manager like Cocoapods or Carthage.

You can find more explanation on what exactly “static framework” means from Carthage README.

To examine your current project:

  • Go to “Build Settings”.
  • Pick any framework under “Targets”.
  • Select “Build Settings” tab.
  • Search for MACH_O_TYPE
Mach-O Type

Click to reveal the list of available types. To know more about each Mach-O type, check the Mach-O Programming Topics.

To link the framework statically, choose “Static Library”.

Cocoapods make static linking framework easy. Check out use_framework!. Set :linkage key as :static.

To be honest, I am not super clear the advantage of static framework over static library since, in both cases, Mach-O type is set to “static library”. The code in your static framework becomes part of the binary of your app executable file. That means you still need to create resource bundle for any assets in your framework. Maybe that’s why SwiftPM creates static library instead?

My suggestion… use a dependency manager. Cocoapods and SwiftPM are what I am most familiar with. Specifying static or dynamic linkage is super easy.

--

--

billibala
The Startup

Indie developer on everything Apple — macOS, iOS, watchOS, etc. I build great apps: Sched, Eventbrite, Eventbrite Organizer (Neon). Ping me for projects.