Cordova (tools) - config XML explanation

Config. What is XML and what is its function

Config.xml is a global configuration file of cordova project It can control some global configurations of the whole project To facilitate the use of cordova CLI, config XML is put here, which is actually under the project root directory

 app/config.xml. 

It should be noted that before version 3.3.1-0.2.0, the file existed in APP / www / config XML, and it is still supported here. When using CLI to build a project, the file version is passively copied to different platform subdirectories.

Config. For a new project XML file

<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>HelloCordova</name>
    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="dev@cordova.apache.org" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <plugin name="cordova-plugin-whitelist" spec="1" />
    <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:*" />
    <platform name="android">
        <allow-intent href="market:*" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
</widget>

widget

config. The root element of the XML document

Here are the widget properties

attribute

describe

id(string)

Required field, identification of the application

version(string)

The field must be the version of the application. This version number corresponds to the actual version number of the project

android-versionCode(string)

Android version settings

defaultlocale

Default language ID for iOS settings

ios-CFBundleVersion(string)

bundleVersion version setting of ios version

osx-CFBundleVersion(string)

bundleVersion version number setting of mac version

windows-packageVersion(string)

window - bundle settings

packageName(string)

Package name of Windows package

xmlns(string)

Required field, direct default http://www.w3.org/ns/widgets Just fine. Don't worry

xmlns:cdv(string)

Required field, direct default http://cordova.apache.org/ns/1.0 Just fine. Don't worry

In addition to attributes, the following tags can also be included to control the corresponding functions

label

describe

attribute

<name>HelloCordova</name>

Specify the name of the application. This name appears on the screen of the device. For example, the mobile phone screen will display this app called HelloCordova

description

Specify app description information (displayed on the app store)

author

Contact information (displayed on the app store)

email(string) - required, email: href(string) - required, author's home page

content

The start page of the application. The default value is index HTML

src(string) - required, page path

access

The * can be used to represent any specific domain name, and the * can also be defined as a white list.

origin(string) - required, url

allow-navigation

It is used for top-level navigation jump and is applicable to WebView. For detailed usage, refer to Cordova plugin whitelist

href(string) - required, URL

allow-intent

It is used for application control and allows the system to be opened. If it is not filled in, it is open by default

href(string) - required, URL

engine

For restoring versions

name(string) - the name of the platform to be recovered. spec(string) - the platform version to be recovered

plugin

Specify the details of which plug-ins are preparing to restore. When a plug-in is added using the -- save flag, this element is automatically added to the project's config xml.

preference

Set the name / value properties of various option pairs. The name of each preference is case sensitive. Many preferences are unique and specific platforms, and for the detailed meaning of each representative, please refer to the official documents. Too many are not listed one by one

The following table lists all specific names

feature

It is used to specify some plug-in parameters, such as what package to retrieve from the plug-in code, and determine whether the plug-in code is initialized during the initialization of web page view.

platform

When using the CLI to build applications, it is sometimes necessary to specify platform specific preferences or other elements. Use the element to specify that it should only appear in a platform specific - config Configuration in XML file.

hook

When some behaviors of cordova occur, call the custom script, such as < hook type = "after_plugin_install" SRC = "scripts / afterpluginstall. JS" / > after the plug-in installation is completed, execute afterpluginstall js

<preference name="DisallowOverscroll" value="true"/>
<preference name="Fullscreen" value="true" />
<preference name="BackgroundColor" value="0xff0000ff"/>
<preference name="HideKeyboardFormAccessoryBar" value="true"/>
<preference name="Orientation" value="landscape" />

<!-- iOS only preferences -->
<preference name="EnableViewportScale" value="true"/>
<preference name="MediaPlaybackAllowsAirPlay" value="false"/>
<preference name="MediaPlaybackRequiresUserAction" value="true"/>
<preference name="AllowInlineMediaPlayback" value="true"/>
<preference name="BackupWebStorage" value="local"/>
<preference name="TopActivityIndicator" value="white"/>
<preference name="SuppressesIncrementalRendering" value="true"/>
<preference name="GapBetweenPages" value="0"/>
<preference name="PageLength" value="0"/>
<preference name="PaginationBreakingMode" value="page"/>
<preference name="PaginationMode" value="unpaginated"/>
<preference name="UIWebViewDecelerationSpeed" value="fast" />
<preference name="ErrorUrl" value="myErrorPage.html"/>
<preference name="OverrideUserAgent" value="Mozilla/5.0 My Browser" />
<preference name="AppendUserAgent" value="My Browser" />
<preference name="target-device" value="universal" />
<preference name="deployment-target" value="7.0" />
<preference name="CordovaWebViewEngine" value="CDVUIWebViewEngine" />
<preference name="SuppressesLongPressGesture" value="true" />
<preference name="Suppresses3DTouchGesture" value="true" />

<!-- Android only preferences -->
<preference name="KeepRunning" value="false"/>
<preference name="LoadUrlTimeoutValue" value="10000"/>
<preference name="InAppBrowserStorageEnabled" value="true"/>
<preference name="LoadingDialog" value="My Title,My Message"/>
<preference name="ErrorUrl" value="myErrorPage.html"/>
<preference name="ShowTitle" value="true"/>
<preference name="LogLevel" value="VERBOSE"/>
<preference name="AndroidLaunchMode" value="singleTop"/>
<preference name="DefaultVolumeStream" value="call" />
<preference name="OverrideUserAgent" value="Mozilla/5.0 My Browser" />
<preference name="AppendUserAgent" value="My Browser" />

<!-- Windows only preferences -->
<preference name="windows-phone-target-version" value="8.1" />
<preference name="windows-target-version" value="8.1" />
<preference name="Windows.Universal" value="10.0.10240.0" />
<preference name="WindowsDefaultUriPrefix" value="ms-appx://" />
<preference name="Windows.Mobile-MaxVersionTested" value="10.0.10031.0" />
<preference name="Windows.Universal-MinVersion" value="10.0.0.0" />
<preference name="WindowsStoreIdentityName" value="Cordova.Example.ApplicationDataSample" />
<preference name="WindowsStorePublisherName" value="CN=Contoso Corp, O=Contoso Corp, L=Redmond, S=Washington, C=US" />
<preference name="WindowsToastCapable" value="true" />
<preference name="uap-target-min-version" value="10.0.10586.0" />

<!-- BlackBerry only preferences -->
<preference name="ChildBrowser" value="disable"/>
<preference name="PopupBlocker" value="enable"/>
<preference name="WebSecurity" value="disable"/>

<!-- OS X only preferences -->
<preference name="HideMousePointer" value="5"/>
<preference name="OSXLocalStoragePath" value="~/.myapp/database"/>
<preference name="WindowSize" value="800x400"/>
<preference name="EnableWebGL" value="true"/>

Added by keeps21 on Wed, 09 Mar 2022 02:56:39 +0200