Automatically add dynamic link library to embedded frameworks via Cocoapods

I am creating a custom Objective-C framework (dynamic link library) and trying to pull it into a consumer application using Cocoapods. If I don't add the framework as an inline binary, I get a nasty runtime error:

dyld: Library not loaded: @rpath/MyFramework.framework/MyFramework
Referenced from: /private/var/mobile/Containers/Bundle/Application/XXX/MyFramework.app/MyFramework
Reason: image not found

      

I understand that as a third party custom framework, I have to add it as an embedded binary (due to Apple's concerns about dynamically linking random frameworks). Is it correct?

If not, can I modify my framework or Podspec file in any way so I don't need to embed it (without making it a static library)?

Otherwise, is there a way to automate adding the framework to embedded binaries on pod install

?

+3


source to share


2 answers


By default, cocoapods tries to link containers as static libraries. You can force cocoapods to use frameworks instead by adding use_frameworks! to your subfile. Or you can probably try to set correctly xcconfig

or vendored_framework

in your podspec file the libraries to link to your map. I saw a good example in the Sparkle project podspec file . Sparkle uses a workaround vendored_framework

to get dynamic linking working on OSX (I guess due to this issue in cocoapods repo mode).



+2


source


I had this exact problem (Objective C framework built as a module with dynamic link library) and finally found a solution:

After installing the pod, you should go to the main Build Phases project in the Embed Pods Framework and add MyFramework.framework to the Input Files section. If your Framework is distributed with a package, you must add it to the Copy Resources section of the same tab.

Unfortunately, this has to be done by the person using your framework. If you have a solution that doesn't require anything on the user side, please let me know.



See screenshot here

Update:

It looks like if you don't provide the module name and add your framework to the vendored_framework inside the podspec, the steps I mentioned above are unnecessary, so no interaction is required on the user side.

0


source







All Articles