I’m attempting to build a capacitor plugin which requires a 3rd party framework for iOS. So my setup looks like this:
my-ionic-app-for-testing ← my-capacitor-plugin ← 3rd-party-framework
Presently, I can get my-capacitor-plugin to compile with the 3rd-party-framework, but when I include my-capacitor-plugin into my-ionic-app-for-testing, I get compile errors “3rd-party-framework” not found.
Additional Details: I’m guessing I made a mistake in how I attempted to create this dependency chain.
my-capacitor-plugin ← 3rd-party-framework
The 3rd-party-framework recommends installing it using the Carthage build tool. I create my-capacitor-plugin/Cartfile, include the dependency I need, and run $ carthage update
. This creates the my-capacitor-plugin/Carthage/Build/iOS/3rd-party.framework directory. In the Xcode ‘general’ tab, I drop this folder into ‘Frameworks and Libraries’ for Pods with targets “Capacitor” and “Pods-Plugin”, and for Plugin with target “Plugin”. At this point I import the 3rd-party-framework into Plugin.swift (import ThirdParty
), the project then builds in Xcode. (It is perhaps worth noting that the 3rd-party-framework itself is written in ObjectiveC, though xcode seems to know how to translate this into a swift import on its own.)
my-ionic-app-for-testing ← my-capacitor-plugin
In my-ionic-app-for-testing/package.json I have…
“dependencies”: {
…
“my-capacitor-plugin”: “file:…/my-capacitor-plugin”,
…
},
where the filepath points to the root of the my-capacitor-plugin project. I build the project with:
$ npm i
$ ionic build
$ npx cap sync
I try building with xcode, pointing to my-ionic-app-for-testing/ios/App/App.xcworkspace, where I get the above “3rd-party-framework” not found errors.
In looking around, this post swift - How to embed third party framework on ionic capacitor custom plugin? - Stack Overflow suggests I need to additionally edit my-capacitor-plugin/MyCapacitorPlugin.podspec. Other posts have suggested I need to add additional run scripts or copy file scripts within the my-capacitor-plugin xcode project. I haven’t gotten any permutation of these ideas to work.
Any help would be greatly appreciated