The config.xml File

The config.xml File

Many aspects of an app's behavior can be controlled with a global configuration file, config.xml. This platform-agnostic XML file is arranged based on the W3C's Packaged Web Apps (Widgets) specification, and extended to specify core Cordova API features, plugins, and platform-specific settings.

For projects created with the Cordova CLI (described in The Command-Line Interface), this file can be found in the top-level directory:

    app/config.xml

Note that before version 3.3.1-0.2.0, the file existed at app/www/config.xml, and that having it here is still supported.

When using the CLI to build a project, versions of this file are passively copied into various platforms/ subdirectories, for example:

    app/platforms/ios/AppName/config.xml
    app/platforms/blackberry10/www/config.xml
    app/platforms/android/res/xml/config.xml

This section details global and cross-platform configuration options. See the following sections for platform-specific options:

In addition to the various configuration options detailed below, you can also configure an application's core set of images for each target platform. See Icons and Splash Screens for more information.

Core Configuration Elements

This example shows the default config.xml generated by the CLI's create command, described in The Command-Line Interface:

    <widget id="com.example.hello" version="0.0.1">
        <name>HelloWorld</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="*" />
    </widget>

The following configuration elements appear in the top-level config.xml file, and are supported across all supported Cordova platforms:

Additional Versioning

Both, Android and iOS support a second version string (or number) in addition to the one visible in app stores, versionCode for Android and CFBundleVersion for iOS. Below is an example that explicitly sets versionCode and CFBundleVersion

    <widget id="io.cordova.hellocordova"
      version="0.0.1"
      android-versionCode="7"
      ios-CFBundleVersion="3.3.3">

If alternative version is not specified, the following defaults will be used:

    // assuming version = MAJOR.MINOR.PATCH-whatever
    versionCode = PATCH + MINOR * 100 + MAJOR * 10000
    CFBundleVersion = "MAJOR.MINOR.PATCH"

Global Preferences

The following global preferences apply to all platforms:

Multi-Platform Preferences

The following preferences apply to more than one platform, but not to all of them:

The feature Element

If you use the CLI to build applications, you use the plugin command to enable device APIs. This does not modify the top-level config.xml file, so the <feature> element does not apply to your workflow. If you work directly in an SDK and using the platform-specific config.xml file as source, you use the <feature> tag to enable device-level APIs and external plugins. They often appear with custom values in platform-specific config.xml files. For example, here is how to specify the Device API for Android projects:

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

Here is how the element appears for iOS projects:

    <feature name="Device">
        <param name="ios-package" value="CDVDevice" />
    </feature>

See the API Reference for details on how to specify each feature. See the Plugin Development Guide for more information on plugins.

The platform Element

When using the CLI to build applications, it is sometimes necessary to specify preferences or other elements specific to a particular platform. Use the <platform> element to specify configuration that should only appear in a single platform-specific config.xml file. For example, here is how to specify that only android should use the Fullscreen preference:

    <platform name="android">
        <preference name="Fullscreen" value="true" />
    </platform>