Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-12594

Local development of plugins with variables need variables in fetch.json

    XMLWordPrintableJSON

Details

    Description

      Consider a plugin that defined a preference in its plugin.xml

      When you use the CLI feature to save plugins into config.xml and also add the variables for this plugin, the CLI complains when adding the plugin during platform restore (missing variables):

      plugin.xml
      <?xml version="1.0" encoding="UTF-8"?>
      <plugin
          xmlns="http://apache.org/cordova/ns/plugins/1.0"
          xmlns:android="http://schemas.android.com/apk/res/android"
          id="cordova-plugin" version="1.0">
      
          <preference name="COMPANY_NAME" />
      
      
      config.xml
      <plugin name="cordova-plugin" spec="cordova-plugin-insert-io">
              <variable name="COMPANY_NAME" value="acme" />
      

      When removing a platform and re-adding it this is the result:

      Installing "cordova-plugin" for android
      Failed to install 'cordova-plugin':Error: Variable(s) missing: COMPANY_NAME
          at /Users/xxx/.nvm/versions/node/v6.2.0/lib/node_modules/cordova/node_modules/cordova-lib/src/plugman/install.js:362:23
          at _fulfilled (/Users/xxx/.nvm/versions/node/v6.2.0/lib/node_modules/cordova/node_modules/q/q.js:787:54)
          at self.promiseDispatch.done (/Users/xxx/.nvm/versions/node/v6.2.0/lib/node_modules/cordova/node_modules/q/q.js:816:30)
          at Promise.promise.promiseDispatch (/Users/xxx/.nvm/versions/node/v6.2.0/lib/node_modules/cordova/node_modules/q/q.js:749:13)
          at /Users/xxx/.nvm/versions/node/v6.2.0/lib/node_modules/cordova/node_modules/q/q.js:557:44
          at flush (/Users/xxx/.nvm/versions/node/v6.2.0/lib/node_modules/cordova/node_modules/q/q.js:108:17)
          at _combinedTickCallback (internal/process/next_tick.js:67:7)
          at process._tickCallback (internal/process/next_tick.js:98:9)
      Error: Variable(s) missing: INSERT_COMPANY_NAME
      

      It seems, the CLI checks the fetch.json file, and if that does not contain the variables, it fails with this error. Manually adding the variables to the fetch.json file, or re-installing the plugin helps (reinstalling rewrites the fetch.json file).

      That means, if we add a variable to our plugin during plugin development, we would have to remove the plugin (unlink) it first, and then re-add it, specifying all the variables at the CLI.

      How it should actually work is that config.xml has precedence over whatever it says in fetch.json. Or get rid of fetch.json alltogether. I think its only there for historical reasons?

      Attachments

        Activity

          People

            Unassigned Unassigned
            pke Philipp Kursawe
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated: