3
votes

There's something I find quite confusing about phonegap/cordova plugins.

For example I can run

cordova plugin add cordova-plugin-whitelist

OR

phonegap plugin add cordova-plugin-whitelist

Doing so does not modify the config.xml file


Or I can add to config.xml:

<plugin name="cordova-plugin-whitelist" spec="1.1.0" />

OR

<gap:plugin name="cordova-plugin-whitelist" spec="1.1.0" />


What are exactly the differences between all these different plugin installations? Which one should I use in the end?

I want the same plugins to be available on all the other developers computers, in the exact same version to have a stable and reproductible environment (and the CLI does not seem to specify the version...). Should I include anything of my /plugins folder to Git?

Note: if it matters, I don't know yet which of cordova or phonegap CLI I'll use in the future, as I don't know yet if I'll use Phonegap Build. For the moment both CLI (v5.1.1) seems to work fine.

4

4 Answers

6
votes

Use:

cordova plugin add cordova-plugin-whitelist --save

Source

2
votes

The answer is very long. Please read.

What are exactly the differences between all these different plugin installations? Which one should I use in the end?

Up until this date (2015-11-05) and for a bit longer, there are subtle differences in the different plugins. Cordova and Phonegap are working to remove that. For all intensive purposes you should use the *NEW* plugin repository

NEW Plugin Repository: http://cordova.apache.org/plugins/

NEW CORE Plugin List: http://cordova.apache.org/docs/en/5.1.1/cordova/plugins/pluginapis.html (Note: those plugin not on this list are not core.)

I want the same plugins to be available on all the other developers computers, in the exact same version to have a stable and reproductible environment (and the CLI does not seem to specify the version...). Should I include anything of my /plugins folder to Git?

No. For now, just use the current NPM system. You may want to use the --save option so that you retain a copy of the plugin you are using. CAUTION: this has side effects. Read the Cordova docs for more information.

NOTE FOR TEAMS: Many frameworks want you to use the "leading" edge, sold as "latest and greatest". This has many, many side effects. Cordova and Phonegap both have an versioning option. Learn to use it.

This will help: http://devgirl.org/2014/11/07/cordovaphonegap-version-confusion/


HOW TO apply the Cordova/Phonegap the whitelist system

I Quote:

Here is the breakdown.

For the whitelist system used with Cordova, there is actually four (4) unrelated systems in place.

  1. legacy-whitelist plugin (avoid) was the previous whitelist system. It is provided for backwards compatibilty only.
  2. whitelist plugin (Cordova's) is the new whitelist system. It is required as of Cordova Tools 4.0.0. It has three (3) parts.
  3. W3's CSP (Content Security Policy Level 2) is a whitelist system that is implemented webpage by webpage. It is required as of Cordova Tools 5.0.0. It has sixteen (16) parts.
  4. Apple's ATS (App Transport Security) is a whitelist system exclusive to iOS. It required as of iOS9. It is implemented in the Info.plist
1
votes

You should start reading about the difference between PhoneGap and Cordova (there is none) - more information can be found here: Difference between PhoneGap and Cordova.

That the command cordova plugin add cordova-plugin-console doesn't modify the config.xml must be an issue on your system. I just tried it, to be sure, this works in 5.1.1 as expected and it does.

config.xml after fresh build without adding plugins:

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.example.com" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <preference name="AllowInlineMediaPlayback" value="false" />
    <preference name="BackupWebStorage" value="cloud" />
    <preference name="DisallowOverscroll" value="false" />
    <preference name="EnableViewportScale" value="false" />
    <preference name="KeyboardDisplayRequiresUserAction" value="true" />
    <preference name="MediaPlaybackRequiresUserAction" value="false" />
    <preference name="SuppressesIncrementalRendering" value="false" />
    <preference name="GapBetweenPages" value="0" />
    <preference name="PageLength" value="0" />
    <preference name="PaginationBreakingMode" value="page" />
    <preference name="PaginationMode" value="unpaginated" />
    <feature name="LocalStorage">
        <param name="ios-package" value="CDVLocalStorage" />
    </feature>
    <allow-intent href="itms:*" />
    <allow-intent href="itms-apps:*" />
    <name>test</name>
    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="[email protected]" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
</widget>

After adding cordova plugin add cordova-plugin-console there are three new lines at the bottom:

<feature name="Console">
    <param name="ios-package" value="CDVLogger" />
</feature>
  • gap: is a PhoneGap setting for your config.xml
  • Adding a Plugin in a different version will work with this command: cordova plugin add [PLUGIN_ID]@[VERSION]
  • I would recommend you to set up a repository with the plugins you need and than someone should take an eye on this and update the plugins so that the others can fork those plugins to their computers if they need them in that version.
  • Just use one of them, PhoneGap or Cordova as there is no difference.
0
votes
<gap:plugin name="cordova-plugin-whitelist"npm />

Use this one sometimes it wont work if you use this code

<gap:plugin name="cordova-plugin-whitelist" spec="1.1.0" />