Search code examples
iosswiftcocoapodsstatic-libraries

Using static libraries with CocoaPods 1.5 no such module at import


With CocoaPods 1.5 released I am trying to migrate from having 10-15 dynamic pods in my projects to having them as static libraries instead, with the goal of speeding up my app start time.

At this stage my simple (i.e., simplistic) attempt has been to remove the use_frameworks command when running my pod install. This indeed transforms my pods to static libraries. But it also produces a series of "No Such Module" throughout my project when trying to import my Pods (e.g., "No such Module PureLayout or no such Module FirebaseMessaging).

I am not super versed in all the intricacies of pods and dynamic/ static libraries and have tried for the past day to find good documentation on how to properly import, use and deploy static libraries for a Swift Project but could not find clear guidelines.

I am using Xcode 10.1 and CocoaPod 1.5.2 (client version).

Could anyone help me by providing links to detailed instructions on how to move from dynamic to static libraries?

Thanks a ton!


Solution

  • CocoaPods 1.5.0 introduced use_modular_headers! to still provide module support with static libraries. Details in the release notes.

    Alternatively you could change the modular imports in your sources to file imports.

    I'd also recommend trying out the CocoaPods 1.6.0 beta since it has several fixes for static/dynamic library and framework issues.

    2020 Update

    CocoaPods 1.9.0 introduced use_frameworks! :linkage => :static which will generate full frameworks with statically linked libraries and module map files. This is typically an even better approach than use_modular_headers!.