Lightning Tips are small posts that provide an easy and to-the-point solution for common problems that cross-platform mobile app developers face.
Updating your Cordova/Phonegap hybrid mobile app project to get the latest platform specific support is a periodic task all hybrid app developers using this cool platform must undergo. Since the core plugins tend to be upgraded alongside with the platform upgrades, it’s best to upgrade those too by uninstalling and installing all your project’s plugins. This being a tedious task, it’s time to show you how one can upgrade all your project plugins at once.
Instead of executing the time consuming task of removing and adding all your projects plugin one by one, let’s look at one way to perform this semi automatic.
(Please note that we assume that your plugins are being listed in their interdependant order, ie: cordova-plugin-file is shown before cordova-plugin-file-transfer in the listing. The transfer plugin is dependant on the file plugin thus uses its name with a postfix of -transfer. This ensures it is listed below the plugin it relies on
On Mac OS we can use a semi-automatic solution (solution source) that uses the cordova plugins list command , pipes the output of that command and reads each plugin line to uninstall and install it one-by-one for you. Fast and simple, let’s lock & load:
[crayon-5b7c9dd459959258261389/] Although you could omit the save command it is advised to keep this so the plugins used are stored in the platform specific plugin registration .json file so
On Windows we could run the same in batch-file flavour but after some experimenting it seems that running the remove commands are not finished executing before the add lines are called thus making direct execution fail. Even with the & that enables DOS commands to be chained.
[crayon-5b7c9dd45996d050752560/] Whereas the Start /W(ait) command runs the command that follows it and waits for the execution to end the cmd /c makes shure the extra opened execution window will shut down (wether the outcome was success or failure).
And there you have it: If you run these commands they will remove and add your plugins. This will help you update your Cordova project without having to manually remove and (re)add them again.
A simple solution for a time-consuming and common task.