Using the newest version of cocoa pods (0.36) I am able to embed cocoa pods written in swift (e.g. Alamofire) into my swift project. Now I introduced a custom framework of my own into the project, which also wants to depend on Alamofire.
What I did in order to accomplish that is to select add the pods framework to my framework as dependency:
Select the Target for my own embedded Swift Framework (Swift Module) and in the "General" tab in the "Linked frameworks and libraries" I added "Pods.framework" as "Required".
However, that is not enough in order to compile as the classes in my own swift framework can not "import Alamofire" as it is not recognised as "available framework".
Adding the Pods.debug.xcconfig and the Pods.release.xcconfig file to the Configurations for the target of my own swift framework, in other words changing the build settings to do all the changes, that cocoa pods do to the build settings of my iOS App target, solves the problem.
It now builds without a problem. It also runs without a problem in the Simulator and my own embedded swift framework successfully uses the frameworks added by cocoa pods.
HOWEVER if I run the same on a device, it compiles and installs without a problem, but then crashes with a fatal error on launch:
dyld: Library not loaded: @rpath/Pods.framework/Pods Referenced from: /private/var/mobile/Containers/Bundle/Application/32D2F1F8-679F-4A5F-8159-28F1C800D0C6/TestingFrameworks.app/Frameworks/mySwiftFramework.framework/mySwiftFramework Reason: image not found
Apparently not all the settings from the cocoa pods xcconfig file are suited to be added to the build settings of my custom swift framework.
But why does it work in the simulator then? And more important what is the build setting, which I need to correct?
To me it looks like I need to change this build setting:
PODS_FRAMEWORK_BUILD_PATH = $(BUILD_DIR)/$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)/Pods
to something else...
Unfortunately, swift-atomics doesn't support CocoaPods, so you'll need your own Podspec for it.
I identified the problem. There was simply no pods.framework in the Frameworks/ folder of the embedded framework.
This is due to the fact that the Pods-frameworks.sh don't actually copy things in the right directory.
I managed to fix this problem by:
That's it!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With