Swift Package Manager, Static Linking


(McLaren Stanley) #1

Hi Folks,

Some Background:
I’m currently working on an iOS project that has a large number (~62) of dynamic frameworks. As a result this app incurs a relatively large penalty at runtime when the app bundled is initially loaded (~5 seconds on iPhone 6s, by our best estimates). Combining these frameworks is proving to be non-trivial, so I was hoping for an alternative solution to manage all of these modules. Since the Swift Package Manager was initially implemented by linking modules statically, it seemed like an obvious solution.

However, when reading the documentation/code and attempting this myself I found statically linking to be quite difficult. It seems like the command line interface “swift build” does in fact link modules at compile time, but it seems like it no longer does so via .a static libs as was originally stated in the documentation. It also seems difficult to configure the correct iOS architecture apart from manually passing in every Swift complier flag as a parameter. Using the generate-xcodeproj tool seemed very promising, but the biggest disadvantage with that tool is it forms packages into dynamic libraries which brings me back to the original problem.

Is there a clever way to use the Package Manager to reduce the number of dynamic frameworks in my app? Or am I going about this in completely the wrong way?

Thanks in advance,
McLaren