3
votes

Background: I have a cordova 3.0.9 (according to package.json) project installed via npm on linux in a project folder.

Command history as follows (after the npm install of Cordova, and installing the android SDK etc, and creating project folder):

cordova create . com.myproject MyProject 

(all good I get a www dir which has config.xml, and the dummy hello cordova app, etc. This config.xml has the right name of my project etc generated in it by default)

cordova platform add android 

(I get the platforms/android folder etc)

Now I install some plugins

cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-geolocation.git

cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device-orientation.git

This is fine, but also where things get interesting. I note that the plugin installation, as well as adding srcs to the plugins dir also updates my platforms/android/res/xml/config.xml with useful directives for Android like:

<feature name="Geolocation">
  <param name="android-package" value="org.apache.cordova.GeoBroker" />
</feature>

<feature name="Compass">
  <param name="android-package" value="org.apache.cordova.CompassListener" />
</feature>

It important to note that the config.xml in my www dir which I know is necessary to do a "cordova build" just never gets updated with any information related to the plugins I installed, which I am a little concerned about even/especially after reading:

http://docs.phonegap.com/en/3.0.0/config_ref_index.md.html#Configuration%20Reference.

I can sort of answer my own question here, but have some questions/concerns further down.

So logically the config.xml in the www dir, which is still non platform specific remains bland and uninteresting and only contains platform independendant directives. However I'm curious about it as the, platform independant one surely should still know about the plugins? Also the platform specific one (platforms/android/res/xml/config.xml), doesn't even know the name of my project, it's still called "Hello Cordova". This is also somewhat concerning.

So can someone tell me if everything is ok? Specifically:

  1. Does my platform independant config.xml need to know about the plugins I've installed? (is it a bug/TODO that the cli didn't do this?)
  2. Does my platform specific config.xml need to know the right name of my project/app? (again a bug/TODO here?)
  3. If the first two are not bugs, does cordova build process pull in each respective platform specific config.xml at some stage overiding or merging with the platform independant config.xml?
  4. Are there other differences I should be aware of between the two?
  5. Ultimately do I need to manually update www/config.xml (as well as the platform specific files) before I do a "cordova build", as the CLI isn't doing all it could/should?

Thanks in advance.

2
Good answers both, thank you. Cordova CLI on github was the key!JDawgg

2 Answers

3
votes

The README.md on Cordova CLI github page, https://github.com/apache/cordova-cli, have some more info.

The www/config.xml file is your main configuration file. It is used whenever you do a cordova build or some such. But not all properties in it actually matter. Not plugins for instance.

From the README.md

cordova-cli supports changing your application's data via the following elements inside the config.xml file:

  • The user-facing name can be modified via the contents of the element.
  • The package name (AKA bundle identifier or application id) can be modified via the id attribute from the top-level element.
  • The version can be modified via the version attribute from the top-level element.
  • The whitelist can be modified using the elements. Make sure the origin attribute of your element points to a valid URL (you can use * as wildcard). For more information on the whitelisting syntax, see the docs.phonegap.com. You can use either attribute uri (BlackBerry-proprietary) or origin (standards-compliant) to denote the domain.
  • Platform-specific preferences can be customized via tags. See docs.phonegap.com for a list of preferences you can use.
  • The entry/start page for your application can be defined via the element + attribute.

That should mean the following I guess:

  1. No
  2. No, it gets overwritten in the build phase.
  3. Yes, and also touches other files, like AndroidManifest.xml, if platform specific features are used.
  4. Not that I know of.
  5. You need to update it if you add plugins without using cordova cli to do it, i.e. a third party plugin.
0
votes

AFAIK the platform independant config.xml is used mainly by Phonegap Build service. I have experience by myself what you describe.

I will answer based on my humble experience, but would also love to read other opinions answers as the doc is kind of sparse.

  1. No. At least I am using plugins on iOS and everything works correctly on device leaving the CLI to update the platform specifics.

  2. Not sure if bug. I manually update that part, including version. But I have tested my app still on development and AFAI have experienced it doesn't affect meanwhile the app bundle id is set correctly in XCode.

  3. I have seen cordova build taking platform independant info and merging it with the platform specific config file.

  4. I would love to let someone more xperienced to answer.

  5. IMO only update the platform specific file if the platform independant configurations are not propagated to the platform specific.

Related question: Cordova and PhoneGap have different config.xml examples