13

Sorry guys if this is a simple question, which I'm hoping it is. The PhoneGap/Cordova documentation is pretty bad.

So with the directory structure:

/platforms/
   /ios/
   /android/
/plugins/
/www/

Is there anyway to make changes in the parent plugin directory and then have it apply those changes to the different platforms? I'm doing:

cordova prepare

This updates all the HTML from the parent www directory, but my plugins don't seem to get updated.

Hopefully someone can chime in with and give me a "doh!" moment.

normmcgarry
  • 661
  • 2
  • 6
  • 22
  • I had the same issue when building a plugin. If you are modifying the plugin after installing, you edit the JS in the plugins/www location, but the platform specific code needs to be edited in the platform directories. I ended up creating a separate project where I did my plugin work and then when the plugin was ready to deploy I would install it on my actual project. – Dawson Loudon Nov 22 '13 at 00:03

4 Answers4

11

I ran into the same issue. The only way I could consistently get my plugin to update would be to uninstall the plugin completely and reinstall it from scratch.

cordova plugin rm org.apache.cordova.plugin.example
cordova plugin add ../example-app-plugin/

In this example I am installing it from a local directory.

Noah
  • 131
  • 9
4

I'm asking myself this question for a long time, and finally did a little script to make sure everything is up to date:

rm -rf -- platforms/*/
rm -rf platforms/platforms.json

rm -rf -- plugins/*/
rm -rf -- plugins/android.json
rm -rf -- plugins/ios.json
rm -rf -- plugins/fetch.json

cordova prepare

Have not found anything better yet

Sebastien Lorber
  • 89,644
  • 67
  • 288
  • 419
3

Try:

cordova plugin add ../example-app-plugin/ --link

This will work if you are not adding or removing files from your config.xml - in which case, rm/add seem to be the way to go. So if your file structure is pretty much settled, that should get the job done for you.

Marc Trudel
  • 1,244
  • 1
  • 12
  • 19
0

All answers didn't work for me when using cordova@8 or higher, using a file: prefix seems to work:

cordova plugin add file:cordova-plugin-example
Luca Steeb
  • 1,795
  • 4
  • 23
  • 44