PhoneGap Build: npm plugins

PhoneGap Build is changing how they organize their plugins. You will need to make some changes to configxml in Project Properties as a result.

For each PhoneGap plugin you use, you need to add a line to configxml which declares the name of the plugin. PhoneGap Build can then add it to your app. These used to be saved in a folder on PhoneGap’s servers: they are now stored in an npm repository.

(npm stands for Node Package Manager. It’s a way of saving JavaScript files so they can be shared. It’s part of the work done for Node.js. None of this important to know here.)

Here’s the old format:

<gap:plugin name="" />
<gap:plugin name="org.apache.cordova.device" />
<gap:plugin name="org.apache.cordova.contacts" />
<gap:plugin name="com.phonegap.plugins.barcodescanner" />

Here is how to do the exact same thing in the new format:

<gap:plugin name="cordova-plugin-camera" source="npm"  />
<gap:plugin name="cordova-plugin-device" source="npm" />
<gap:plugin name="cordova-plugin-contacts" source="npm" />
<gap:plugin name="cordova-plugin-barcodescanner" source="npm" />

Notice that the names are different and there is a new ‘source’ element.

To get the new names, you need to go into the Cordova npm library:
The names are shown in bold on that page. There are many more plugins in the new repository: 561 when this blog post was written, with more being adding all the time. All the plugins you have been using should be in the npm library – plus a lot of new ones. You should not need to make any other changes to your app.

PhoneGap has deprecated the old library. Furthermore, they have stated that for iOS9, apps will only be able to use the new npm library. It’s time to update your code!

This entry was posted in PhoneGap, tips. Bookmark the permalink.

One Response to PhoneGap Build: npm plugins

  1. Pingback: PhoneGap Build: iOS 9 support delayed | AppStudio Blog

Comments are closed.