How to bundle CocoaPods dependencies with Cordova Plugin?

In recent versions of Cordova, it's recommended to use podspec tag instead of framework tag with type podspec. Here is an example configuration:

<platform name="ios">
    ...
    <podspec>
        <config>
            <source url="https://github.com/CocoaPods/Specs.git"/>
        </config>
        <pods use-frameworks="true">
            <pod name="SwiftyJSON" spec="~> 5.0.0" />
        </pods>
    </podspec>
    ...
</platform>

I just wasted several hours on this so I thought I would put this here for anyone who is interested. Cordova as of Cordova-CLI version 6.4.0/Cordova iOS version 4.3.0 supports direct integration with CocoaPods.

Detailed information is here: https://cordova.apache.org/docs/en/latest/plugin_ref/spec.html

Simply add something like:

<platform name="ios">
    ...Other iOS platform specific declerations...
    <framework src="OpenSSL" type="podspec" spec="~> 1.0.0" />
</platform>

To the plugin.xml file for your plugin. Cordova automatically generates an .xcworkspace. Use that instead of the xcodeproj file and you are good to go.


I couldn't find much info about this either, so I wrote a Cocoapods plugin to help: https://github.com/xdissent/cocoapods-cordova It manages your plugin.xml automatically and builds a universal static library which links in only non-cordova dependencies. Currently a WIP, but I'm using it successfully on a few plugins.


I couldn't find a good solution to this problem so I created a plugin for it, https://github.com/blakgeek/cordova-plugin-cocoapod-support. It adds support for defining Cocoapod dependencies in the plugin.xml. It should be included as a dependency of another plugin and then that plugin can add entries in the ios platform section of the plugin.xml. It supports all of the pod dependency specifications like git repo, configurations, subspecs, etc. Hope this helps someone out.