Variables should to be provided when adding the plugin
E.g:

    cordova plugin add org.some.plugin --variable API_KEY=some_value

Example of a plugin that uses variables:
http://plugins.cordova.io/#/package/com.phonegap.plugins.facebookconnect

Relevant places in the code in cordova-lib:
   Where variables are checked during plugin add:

https://github.com/apache/cordova-lib/blob/master/cordova-lib/src/cordova/plugin.js#L126

https://github.com/apache/cordova-lib/blob/master/cordova-lib/src/plugman/install.js#L296

Here each variable is replaced with its value when generating the "config
munge" which is an object that describes changes that need to be applied to
the platform dir.

https://github.com/apache/cordova-lib/blob/master/cordova-lib/src/plugman/util/config-changes.js#L368


On Wed, Nov 5, 2014 at 5:28 PM, Treggiari, Leo <leo.treggi...@intel.com>
wrote:

> I'm having a hard time understanding exactly how plugin variables work.
> It's probably a level of detail that only plugin developers and tool
> developers need to be concerned about.  I'd appreciate it if someone can
> give me the answers.
>
> 1.  "variables can be indicated by a dollar-sign followed by a series of
> capital letters, digits, or underscores."
>      "To make the variable mandatory, the <platform> tag needs to contain
> a <preference> tag."
>      Does this mean that there are optional and required variables - i.e?
>       -  A variable reference is defined by a lexical element which begins
> with a $ and is followed only by capital letters, digits, or underscores?
>       -  A variable is made mandatory by the presence of a <preference>
> tag which uses the same name with the $ removed?
>       -  Can this <preference> tag be anywhere in the plugin.xml file, or
> must it be the direct child of the <plugin> element or
>          a <platform> element?
>       -  Can the variable references be anywhere or only within strings?
>
> 2.  Where and when are the variables replaced by their value?
>       -  plugin.xml is the only place that the variable value is used and
> only for replacing the variable references?
>       -  When in Cordova CLI do the values get applied - during "add",
> during "prepare"?
>
> 3.   What happens if you combine dependencies with variables.  For
> example, suppose A depends on B, and B requires a variable X.  How do you
> supply the value?
>
> Thanks,
> Leo
>
>

Reply via email to