Search code examples
ioscordovacocoapodscordova-plugins

How to bundle CocoaPods dependencies with Cordova Plugin?


I'm developing a Cordova plugin, and for the iOS platform, I'd like to incorporate a few existing (non-cordova-specific) Cocoapods. I haven't been able to find any info or examples on how to get this working, and I would've expected this to be a fairly common use-case.

Note that I am not trying to use Cordova as a Cocoapod, for which there is a decent amount of information out there, but rather use Cocoapods from within the iOS platform of a Cordova plugin that I'm developing.

Cordova's plugin.xml generally needs to list all project dependencies to bundle things correctly. Does anyone know of a Cordova or PhoneGap plugin which internally uses Cocoapods?


Solution

  • 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.