Framework Target

A Framework target in Xcode builds a reusable bundle of compiled code and public interfaces, separate from an app target, so an app, a widget, or an extension can share the same code without duplicating it.
Why it exists
Large iOS apps often need to share code across multiple executables: the main app, a widget extension, a watch app, a share extension. Compiling that shared code separately from each target avoids duplication and lets teams build and version it independently. A Framework target exists to package that shared code as one reusable, linkable unit.
The mental model
Think of an app target as a finished car and a framework target as a parts supplier building a reusable engine. The engine is built once, tested on its own, and then bolted into multiple cars. It has a defined interface, the parts that connect to the car, while everything inside stays hidden unless the supplier deliberately exposes it.
How it works
Creating a Framework target gives Xcode a different product type that compiles to a Mach-O dynamic library bundled with its headers or Swift module interface. Only symbols marked public or open in Swift are visible to code that imports the framework; everything else stays internal by default. An app or extension target adds the framework under Frameworks, Libraries, and Embedded Content, and for dynamic frameworks must choose Embed and Sign so the framework binary is physically copied into that target's bundle and code signed, not just linked at compile time. Each separate executable, the app, a widget, an extension, needs its own embedded copy.
When it matters
This matters whenever an app ships more than one executable, or when a team wants independently buildable, testable modules. It also affects build times, since a framework can be cached and only rebuilt when its own source changes. The main footgun is linking a framework without embedding it in every executable that needs it, which compiles without error but crashes on launch, and circular dependencies between two framework targets, which fail to build at all.
A concrete example
A team extracts networking and model code into a CoreKit framework shared by the main app and a new Share Extension target. The main app works fine, but the extension crashes immediately on launch with a dyld error reading Library not loaded, CoreKit. The cause is that CoreKit was linked in the extension target but never added under its own Embed and Sign setting, so the compiled binary was missing from the extension's bundle even though the app target had it.
Interview question
An app builds without errors but crashes on launch with a dyld error, Library not loaded, referencing a framework the team built in house. What is the most likely cause?
- a.The app target is missing a bridging header
- b.The framework's minimum deployment target is too low
- c.The framework was compiled with a different Xcode version
- d.The framework is linked but not set to Embed and Sign in that target's build settingsCorrect
Why? this is the answer
Linking and embedding are separate steps; a framework can compile and link fine yet still be missing from the final bundle if it is not embedded, causing a runtime dyld failure. Deployment target mismatches or Xcode version differences typically produce build time errors, not this runtime crash.
Just read this? Test yourself on what you have been reading.
Read the original → developer.apple.com
Put your scrolling time to good use
Learn one idea, try a quiz and save useful cards for revision. Tezvyn makes it easy to learn and stay current in your tech field, a few minutes at a time.
The iPhone app is on the way
We are building it. Until it lands, nothing here is held back from you: every interview card, your saved cards, streaks and the job board all work in Safari, plus hundreds of free practice quizzes of thirty questions each. Sign in and it all carries over to the app the day it arrives.
Want it as an icon? Tap Share at the bottom of Safari, then Add to Home Screen. It opens full screen and the cards you have read stay available offline.
We are hiring for this. Open roles that interview on ios — each one lists the topics its interview covers.
See open roles