I've got a large and complex app which has several dependencies upon 3rd party libraries (installed as pods).
The app is structured according to Model-View-Controller design and there is a requirement to implement the Model part as an .xcframework so it can be included and used in the original app along with a few new apps.
However, Apple documentation states that umbrella frameworks are not supported (Technical Note TN2435).
The Model code has several dependencies which would be totally unfeasible to replace or remove, for example it uses RealmSwift for database storage. Obviously it would be impossible to write one's own database storage scheme in place of using Realm.
However, if my framework uses Realm as a dependency, then its now become an umbrella framework.
So therefore not supported according to Apple documentation. So what are options/solutions?
There are basically two strategies here:
-
Completely hide these dependencies from your framework’s clients.
-
Completely expose these dependencies to your framework’s clients.
In the first strategy, you statically link these dependencies into your framework. However, that may not be the only necessary step. If one of your dependencies exposes types via the Swift or Objective-C language runtimes, you can run into problems if a client of your framework brings in their own copy of that dependency. The standard way around this is for you to rename these types within your copy of this framework. This isn’t fun.
Note Historically this strategy was tricky because Xcode didn’t support static frameworks. That’s no longer an issue. Xcode now supports both static frameworks and mergeable frameworks, which greatly simplify the static linking story.
In the second strategy, you expose these dependencies to your clients by shipping them as separate frameworks. That’s a bit more hassle for your clients, but it avoids the need for renaming. However, that doesn’t mean it’s completely sans drawbacks. If one of your clients uses one of your dependencies directly, you and they need to agree on what version to you. And that raising questions about both API and ABI stability.
An umbrella framework has a very specific technical meaning, and that’s not what you’re talking about here. The term you’re looking for is nested framework.
Notably, the ability to nest frameworks isn’t a critical factor here. Sure, it helps tidy things up when you’re using the second strategy, but it doesn’t actually resolve the most significant issue with the second strategy, that is, agreeing on what version to use.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"