How do I use Cocoapods in an embedded framework?

Assuming in your Podfile you are using the link_with 'MyCustomFramework', where ‘MyCustomFramework’ is your embedded framework name, and have run pod install. Select your Project file (Blue on the top right) and go into “Build Settings“. Then, find ‘Allow non-modular includes in Framework Modules‘ and set it to YES, for both the Project file (blue) and the Custom Framework target (ex. MyCustomFramework – orange “lunchbox case” icon).

Setting build settings for non-modular includes

Then you can include cocoa pods stuff in your main MyCustomFramework.h file.
Including CocoaPods in CustomFramework

Then just import ‘@import MyCustomFramework;’ in your Application target, and you’ll get the rest of the CocoaPods at your disposal. (Ex. showing you access to ‘each’ from ObjectiveSugar).
Importing CustomFramework into AppDelegate

Whether you should do this or not is a separate issue, but this allows your Custom Framework to include the CocoaPods libraries in itself, which then allows the Application target to just include your Custom Framework and gets all the CocoaPods as well.

Sorry for the multiple images, but I like to be visual.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)