Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I use Cocoapods in an embedded framework?

I'm using an embedded framework for my custom views in a new project to take advantage of the new @IBDesignable stuff in Xcode 6 and I'd like to animate said views with Facebook's Pop. I've added Pop to the project using Cocoapods but the embedded framework doesn't have access to those files ('POP/pop.h' file not found).

I tried copying the Cocoapods-related build phases from the app target to the custom framework target but they don't work as-is. What does work is copying the Pop folder into the embedded framework directly, but then Xcode tells me that I've gotta change all of the angle brackets <POP/pop.h> to quotes "POP/pop.h". I'm assuming there's a better way and I'm blanking on it.

like image 290
richrad Avatar asked Jun 12 '14 02:06

richrad


People also ask

What is use frameworks in CocoaPods?

use_frameworks! tells cocoa pods to use dynamic libraries, and was very prevalent at one point due in particular to swift not supporting static libraries, meaning there was no choice - however you often don't need use_frameworks! anymore. As of Xcode 9 beta 4, and CocoaPods 1.5.


1 Answers

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.

like image 129
Anthony Persaud Avatar answered Sep 28 '22 07:09

Anthony Persaud