Is it allowed in iOS - Swift Dynamic Framework - Contains multiple Multiple Static Library

I have developed a framework for my customer, thats a swift dyanmic framework. For code modularization i have divided this framework features in to multiple static libraries as shown in the diagram below. Currently we have on main swift dynamnic framework and it contains 2 static libraries too. Also the first static library here in turn nested with another static library, Key points to note here is

  1. My static libraries contains other third party iOS frameworks
  2. My static libraries using CoccoaPods as the dependency for Alarmofire at the moment.

My questios are

  1. Is there any problem in the current architecture , because i heard nested libraries are not supported in iOS . but since we dont have frameworks nested here, all of our second level frameworks are static libraries only.
  2. What are link/libary search path guidance we needed to take care to make a successful build.
Answered by DTS Engineer in 782789022

Is there any problem in the current architecture

No.

because i heard nested libraries are not supported in iOS.

You’re correct that iOS doesn’t support nested frameworks.

but since we dont have frameworks nested here, all of our second level frameworks are static libraries only.

And also correct that this isn’t an issue for you because everything within your framework is a static library. At build time these are all statically linked together to form the framework’s dynamic library, so there’s no nesting in the final product.


What are link/libary search path guidance we needed to take care to make a successful build.

It’s impossible to answer that without knowing more about your build system. In general Xcode should take care of this stuff for you. My general advice on that front is:

  • If you’re building this stuff from source code, Xcode should just work.

  • If you’re building parts of it separately, which means you end up with a binary build product that’s consumed by Xcode, I recommend that you use an XCFramework for that build product. That allows you to collect all the resources you need into one item, at which point Xcode should do the right thing.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

Is there any problem in the current architecture

No.

because i heard nested libraries are not supported in iOS.

You’re correct that iOS doesn’t support nested frameworks.

but since we dont have frameworks nested here, all of our second level frameworks are static libraries only.

And also correct that this isn’t an issue for you because everything within your framework is a static library. At build time these are all statically linked together to form the framework’s dynamic library, so there’s no nesting in the final product.


What are link/libary search path guidance we needed to take care to make a successful build.

It’s impossible to answer that without knowing more about your build system. In general Xcode should take care of this stuff for you. My general advice on that front is:

  • If you’re building this stuff from source code, Xcode should just work.

  • If you’re building parts of it separately, which means you end up with a binary build product that’s consumed by Xcode, I recommend that you use an XCFramework for that build product. That allows you to collect all the resources you need into one item, at which point Xcode should do the right thing.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

@eskimo thank you so much for the clarification. In one of our static library(Static library 1) contains another thirdparty xcframeworks too. Is that cause any such dependency issues or nested framework issues in the final application?

@eskimo Also how do we leverage swift packages to resolve our issue. But we wanted our main framework to be distributed as binary to our customers. Can you suggest an approach of using swift package manager here ?

In one of our static library … contains another thirdparty xcframeworks too.

A static library can’t contain an XCFramework, it can only depend on that framework. As to what happens there, it depends on the contents of that XCFramework:

  • If it’s a static library, it’ll be linked into your app.

  • If it’s a non-mergeable dynamic library or framework, you’ll need to embed the framework at the top-level of your app as if you depended on it directly.

  • If it’s a mergeable dynamic library or framework, you can to choose when you link to it.

we wanted our main framework to be distributed as binary to our customers.

Swift Package Manager support binary dependencies when targeting an Apple platform. See SE-0272 Package Manager Binary Dependencies.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Is it allowed in iOS - Swift Dynamic Framework - Contains multiple Multiple Static Library
 
 
Q