Search code examples
cordovacordova-plugins

What is the workflow to build and debug Cordova Plugin?


I'm trying to build Cordova plugin that will expose native API to Cordova JS. The plugin will not be published to the public registry.

I'll like to understand what are the tools and flow to use to develop that? The cordova tool has only the ability to add/remove/ls plugin, how should I start a new plugin?

I've try to use don/cordova-plugin-hello but when I try to modify the native implementation of ios and rebuild the project the result XCode project implementation is not updating.


Solution

  • I use xcode for iOS plugins and eclipse for android plugins

    These are the steps I follow:

    1. I create a new cordova project using the cordova CLI.
    2. I open the project from eclipse/xcode
    3. I create the native files for the plugin (.m/.h for ios, .java for android)
    4. I create the common .js on the www folder and link it in the index.html
    5. Finally, I add this to the config.xml

      <feature name="PluginName"> <param name="ios-package" value="iOSPluginClassName" /> <param name="android-package" value="androidPluginClassNameIncludingPackage" /> </feature>