Cordova Plugin: integrate custom plugin with framework as dependency

I have installed on my machine cordova 7.0 & Ionic 3.4.0.
I made a custom plugin using plugman and it’s structured as following:

src - ios & android folders with the native files
www - .js file
plugin.xml
package.json

Adding it to a Ionic 2 project (which is using cordova-ios 4.4.0) works fine, it’s generated as expected and I can use it.

Now I need to add Alamofire framework as a dependency to my plugin. I need it to be handled automatically when a plugin is installed. I saw from the documentation (How to add framework as dependency) that I should add:

<framework src="GoogleCloudMessaging" type="podspec" spec="~> 1.2.0" />

To the plugin.xml in the custom plugin. I added it but when I re-add the plugin into the ionic2 project it is not installing also the framework/pod.

I saw other topics related to mine but neither is helping me. I’ve tried everything, but I can’t get it done.

Also, something weird with the tag from the plugin.xml, according to the documentation is:

Paired with type=“podspec”, this is the spec string for the CocoaPod you want to install (static library only). CocoaPod support only exists in cordova-ios 4.3.0 and cordova-cli 6.4.0. For your plugin, make sure you add the appropriate tags and package.json dependencies to ensure backwards-compatible support.

Isn’t this quite strange, will it work for newer versions of cordova-ios?

Plugin - package.json content:

{
	"name": "cordova-plugin-requestService",
    "version": "1.0.0",
    "author": "*******",
    "private": true,
    "engines": {
        "cordovaDependencies": {
            "1.0.0":  { "cordova-ios": ">=4.4.0" }
        }
	}
}

plugin.xml content:

<!-- iOS -->
<platform name="ios">
    <dependency id="cordova-plugin-add-swift-support" version="^1.6.0" />
    <framework src="Alamofire" type="podspec" spec="~> 4.4.0" />
    <config-file target="config.xml" parent="/*">
        <feature name="requestService">
            <param name="ios-package" value="requestService" />
        </feature>
    </config-file>
    <source-file src="src/ios/requestService.swift" />
</platform>

This question is related to a stackoverflow question:

I changed the topic title to reflect that you are effectively looking for hepl to build a Cordova plugin.

Can you link to that documentation? I suspect this is just poor wording.

You can find it here:
https://cordova.apache.org/docs/en/latest/plugin_ref/spec.html#framework
At: spec(string)

I mainly solved the problems:
-Made a fresh starter of Ionic (with the latest versions of both cordova and ionic) - will migrate to the newer versions because of the incompatibilities between the cli’s and project.

  • Used tag in the plugin.xml of the custom plugin
  • Added platform - without the plugin (for now)
  • Manually add the plugin (it will generate the podfile into the platform and other things)

I have one more issue:
I don’t know if cordova provides a way to add “use_frameworks!” into the Podfile by using only their documentation. I saw another custom plugin that makes this but I want to use cordova.

Plugins are part of Cordova… and some stuff is only supported via plugin.xml and not config.xml.

True, the use_frameworks! generation on the Podfile is already an opened issue. It’s a problem of dynamic and static libraries.
https://issues.apache.org/jira/browse/CB-11893