Guidance on splitting iOS app into static frameworks with assets

Hi,

I am splitting my iOS app into smaller components, the natural way of doing this is to create static libraries that I can link with the main binary. I did succeed at making small static libraries (.a) and link them, but I was struggling with static framework where I have color assets.

Finally I was able to make it work by going to the app target > Build Phases > Copy Bundle Resources and add there the .xcassets from the static framework I created.

The confusion on my side is that the assets are accessed from the Framework code not from the app target code, and the guidance I am asking for is: How to create and link a static framework on iOS so that the framework can load and use it's own defined assets without having to do the Copy Bundle Resources step.

Best Regards, Ion

Replies

the natural way of doing this is to create static libraries that I can link with the main binary.

I disagree. The natural way to do this is to create mergeable frameworks. Those let you have your cake and eat it too.

For the details, see WWDC 2023 Session 10268 Meet mergeable libraries.

Share and Enjoy

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