Coder Social home page Coder Social logo

cordova-custom-config's Introduction

cordova-custom-config plugin Build Status Latest Stable Version Total Downloads

Table of Contents

Overview

The purpose of this plugin is to enable manipulation of native platform configuration files that are not supported out-of-the-box by Cordova/Phonegap CLI.

The plugin uses hook scripts to update iOS and Android platform configuration files based on custom data defined in config.xml.

donate

I dedicate a considerable amount of my free time to developing and maintaining this Cordova plugin, along with my other Open Source software. To help ensure this plugin is kept updated, new features are added and bugfixes are implemented quickly, please donate a couple of dollars (or a little more if you can stretch) as this will help me to afford to dedicate time to its maintenance. Please consider donating if you're using this plugin in an app that makes you money, if you're being paid to make the app, if you're asking for new features or priority bug fixes.

Do I need it?

Manual editing of the platform configuration files in the platforms/ directory is one solution to setting of custom platform configuration. But this is not maintainable across multiple development machines or a CI environment where subsequent build operations may overwrite your changes.

This plugin reads custom preferences from config.xml, which can be committed to version control and therefore applied across multiple development machines, CI environments, and maintained between builds, even if a platform is removed and re-added.

However: recent versions of the Cordova/Phonegap CLI have added official support for <edit-config> and <config-file> blocks in the config.xml (previously they only worked in plugin.xml).

So if all you want to do is insert a block of native config or change a native preference, you probably don't need this plugin at all.

I hope that eventually the Cordova/Phonegap CLI will support all the functionality that this plugin provides and it can be retired.

Until then: there are still some operations that can be performed by this plugin which are not supported by the latest Cordova/Phonegap CLI versions. These include:

  • Overriding default platform preferences set during the cordova prepare operation.
  • Deletion of existing elements/attributes in AndroidManifest.xml
  • Manipulation of build settings in the native iOS Xcode project file project.pbxproj via XCBuildConfiguration blocks.
  • Manipulation of iOS Precompile header files via iOS Precompile Header config blocks
  • Advanced manipulation of iOS Xcode project using xcodefunc.

Important notes

Changes in cordova-custom-config@5

The recent release of [email protected] has introduced backwardly-incompatible breaking changes to the structure of Android projects generated by Cordova.

Therefore a new major version of this plugin (v5) has been released to support these changes. Here are things to be aware of:

  • The location of AndroidManifest.xml has changed in cordova-android@7 but cordova-custom-config@5 should detect which version of cordova-android platform is present in the project and use the correct path.
  • All custom config elements supported by this plugin in config.xml should now be prefixed with custom- for use with cordova-custom-config@5
    • <config-file> => <custom-config-file>
    • <preference> => <custom-preference>
    • <resource> => <custom-resource>
    • This is because cordova-android@7 now attempts to parse <config-file> blocks in the config.xml, so <config-file> blocks intended for this plugin to parse will be picked up by Cordova and can cause build errors (see #135) for an example.
    • Plugin preferences should still however be specified as <preference>
      • e.g. <preference name="cordova-custom-config-autorestore" value="true" />
    • The plugin will detect if the platform project is cordova-android@7 or cordova-android@6 (or below)
      • If cordova-android@6, by default the plugin will support non-prefixed custom config elements
      • If cordova-android@7, by default the plugin will NOT support non-prefixed custom config elements
      • This can be overridden by explicitly setting the parse_unprefixed preference
        • <preference name="cordova-custom-config-parse_unprefixed" value="true" />

Remote build environments

This plugin is intended for the automated application of custom configuration to native platform projects in a local build environment.

This plugin WILL NOT WORK with remote ("Cloud") build environments that do not support the execution of this plugin's hook scripts. This includes:

If you are using another cloud-based Cordova/Phonegap build service and find this plugin doesn't work, the reason is probably also the same.

FWIW: if you are professionally developing Cordova/Phonegap apps, you are eventually going to find it preferable to build locally.

Installation

The plugin is registered as cordova-custom-config on npm (requires Cordova CLI 5.0.0+)

cordova-custom-config@4+ requires the plugin to be installed via the cordova-fetch mechanism in order to satisfy its package dependencies by installing it via npm.

Therefore a Cordova CLI version of cordova@7+ is required to install the plugin:

$ cordova plugin add cordova-custom-config

Or [email protected]+ if the --fetch option is specified explicitly:

$ cordova plugin add cordova-custom-config --fetch

Usage

The hook scripts included in this plugin are run after each platform prepare operation and apply preferences dictated by custom keys in the project config.xml file to the relevant platform config files. As such, all you need to do to "use" this plugin is include the relevant keys in your config.xml and the scripts will take care of the rest when you build your project.

IMPORTANT: As of cordova-custom-config@5, this plugin expects that custom configuration keys will be prefixed with <custom- in order to distinguish them from the Cordova configuration keys. For example, for a preference intended for this plugin to parse you should use <custom-preference> but for a preference intended for Cordova to parse you should use <preference>

NOTE: There are no run-time source files included in this plugin - it is simply a convenient package of hook scripts.

Removable preferences via backup/restore

By default, any changes made by this plugin to platform config files are irreversible - i.e. if you want to undo changes made by the plugin, you'll need to remove then re-add the Cordova platform, for example:

cordova platform rm android && cordova platform add android

However, if you want the changes made to be reversible, you can enable auto-backup/restore functionality by adding the following preference inside the top-level <widget> element of your config.xml:

<preference name="cordova-custom-config-autorestore" value="true" />

When the first prepare operation runs after the plugin is installed, it will make backup copies of the original configuration files before it makes any modifications. These backup copies are stored in plugins/cordova-custom-config/backup/ and will be restored before each prepare operation, allowing Cordova to make modifications and then the plugin to make further modifications after the prepare.

This means changes made by the plugin are reversible, so removing a custom element from the config.xml will remove it from the platform configuration file on the next prepare operation and uninstalling the plugin will restore the configuration files to their original state (before the plugin made any modifications).

Consequently, any manual changes made to the platform configuration files in platforms/ after installing the plugin will be overwritten by the plugin on the next prepare operation.

To prevent auto-restoring of backups and make manual changes to platform configuration files persist, remove the autorestore preference from the config.xml

Preferences

Preferences are set by defining a <custom-preference> element in the config.xml, e.g. <custom-preference name="android-launchMode" value="singleTop" />

  1. Preferences defined outside of the platform element will apply to all platforms
  2. Preferences defined inside a platform element will apply only to the specified platform
  3. Platform preferences take precedence over common preferences
  4. Platform-specific preferences must be prefixed with the platform name (e.g. name="ios-somepref") and be defined inside a platform element.

Config blocks

<custom-config-file> blocks allow platform-specific chunks of config to be defined as an XML subtree in the config.xml, which is then applied to the appropriate platform configuration file by the plugin.

  1. config-file elements MUST be defined inside a platform element, otherwise they will be ignored.
  2. config-file target attributes specify the target file to update. (AndroidManifest.xml or *-Info.plist)
  3. config-file parent attributes specify the parent element (AndroidManifest.xml) or parent key (*-Info.plist) that the child data will replace or be appended to.
  4. config-file elements are uniquely indexed by target AND parent for each platform.
  5. If there are multiple config-file's defined with the same target AND parent, the last config-file will be used
  6. Elements defined WITHIN a config-file will replace or be appended to the same elements relative to the parent element
  7. If a unique config-file contains multiples of the same elements (other than uses-permission elements which are selected by by the uses-permission name attribute), the last defined element will be retrieved.

Android

The plugin currently supports setting of custom config only in platforms/android/AndroidManifest.xml. For a list of possible manifest values see http://developer.android.com/guide/topics/manifest/manifest-intro.html

Android preferences

Note: [email protected] adds support for <edit-config> blocks in config.xml, which enables you to achieve similar manipulation of Android preferences without needing this plugin.

  • <custom-preference> elements in config.xml are used to set set attributes on existing elements in the AndroidManifest.xml.
    • e.g. <custom-preference name="android-manifest/@android:hardwareAccelerated" value="false" />
    • will result in AndroidManifest.xml: <manifest android:hardwareAccelerated="false">
  • Sometimes there plugins set some defaults in AndroidManifest.xml that you may not want. It is also possible to delete nodes using the preferences and the delete="true" attribute.
    • e.g. <custom-preference name="android-manifest/uses-permission/[@android:name='android.permission.WRITE_CONTACTS']" delete="true" />
    • will delete the existing node <uses-permission android:name="android.permission.WRITE_CONTACTS" />

Android namespace attribute

Important: In order to user the android: namespace in preferences within your config.xml, you must include the android namespace attribute on the root <widget> element. The namespace attribute fragment is:

xmlns:android="http://schemas.android.com/apk/res/android"

so your <widget> element should look something like:

<widget
    id="com.my.app"
    version="0.0.1"
    xmlns="http://www.w3.org/ns/widgets"
    xmlns:cdv="http://cordova.apache.org/ns/1.0"
    xmlns:android="http://schemas.android.com/apk/res/android">

XPath preferences

Android manifest preferences are set by using XPaths in the preference name to define which element attribute the value should be applied to.

The preference name should be prefixed with android-manifest then follow with an XPath which specifies the element and attribute to apple the value to.

For example:

<custom-preference name="android-manifest/application/activity/@android:launchMode" value="singleTask" />

This preference specifies that the launchMode attribute should be given a value of singleTask:

<activity android:launchMode="singleTask">

If your manifest contains other activities, you should specify the activity name in the XPath. Note that the activity name for Cordova 4.2.0 and below was "CordovaApp" whereas Cordova 4.3.0 and above is "MainActivity". For example:

<custom-preference name="android-manifest/application/activity[@android:name='MainActivity']/@android:launchMode" value="singleTask" />

If the attribute you are setting is on the root <manifest> element, just omit the element name and specify the attribute. For example:

<custom-preference name="android-manifest/@android:installLocation" value="auto" />

Android config blocks

  • <custom-config-file> blocks are use to define chunks of config an XML subtree, to be inserted into AndroidManifest.xml
  • the target attribute must be set to AndroidManifest.xml: <custom-config-file target="AndroidManifest.xml">
  • the parent attribute defines an Xpath to the parent element in the AndroidManifest.xml under which the XML subtree block should be inserted
    • to insert a block under the root <manifest> element, use parent="/*"
    • to insert a block under a descendant of <manifest>, use an Xpath prefixed with ./ e.g parent="./application/activity" will insert the block under /manifest/application/activity
  • the child elements inside the <custom-config-file> block will be inserted under the parent element.

For example:

<custom-config-file target="AndroidManifest.xml" parent="./application">
    <some-element />
</custom-config-file>

will result in AndroidManifest.xml with:

<manifest ...>
    <application ...>
        <some-element />
    </application>
</manifest>

NOTE: By default, if the specified parent element contains an existing child element of the same name as that defined in the XML subtree, the existing element will be overwritten. For example:

<custom-config-file target="AndroidManifest.xml">
    <application android:name="MyApp" />
</custom-config-file>

will replace the existing <application> element(s).

To force the preservation (rather than replacement) of existing child elements, you can use the mode="add" attribute. So for the example above:

<custom-config-file target="AndroidManifest.xml" mode="add">
    <application android:name="MyApp" />
</custom-config-file>

will preserve the existing <application> element(s).

Android example

config.xml:

<platform name="android">
    <!-- custom preferences examples -->
    <custom-preference name="android-manifest/application/activity/@android:windowSoftInputMode" value="stateVisible" />
    <custom-preference name="android-manifest/@android:installLocation" value="auto" />
    <custom-preference name="android-manifest/application/@android:hardwareAccelerated" value="false" />
    <custom-preference name="android-manifest/@android:hardwareAccelerated" value="false" />
    <custom-preference name="android-manifest/application/activity/@android:configChanges" value="orientation" />
    <custom-preference name="android-manifest/application/activity/@android:theme" value="@android:style/Theme.Material" />

    <!-- specify activity name -->
    <custom-preference name="android-manifest/application/activity[@android:name='MainActivity']/@android:launchMode" value="singleTask" />
    
    <!-- Delete an element -->
    <custom-preference name="android-manifest/application/activity[@android:name='DeleteMe']" delete="true" />


    <!-- These preferences are actually available in Cordova by default although not currently documented -->
    <custom-preference name="android-minSdkVersion" value="10" />
    <custom-preference name="android-maxSdkVersion" value="22" />
    <custom-preference name="android-targetSdkVersion" value="21" />

    <!-- Or you can use a custom-config-file element for them -->
    <custom-config-file target="AndroidManifest.xml" parent="/*">
        <uses-sdk android:maxSdkVersion="22" android:minSdkVersion="10" android:targetSdkVersion="21" />
    </custom-config-file>


    <!-- custom config example -->
     <custom-config-file target="AndroidManifest.xml" parent="/*">
        <supports-screens
            android:xlargeScreens="false"
            android:largeScreens="false"
            android:smallScreens="false" />

        <uses-permission android:name="android.permission.READ_CONTACTS" android:maxSdkVersion="15" />
        <uses-permission android:name="android.permission.WRITE_CONTACTS" />
    </custom-config-file>
    
    <!-- Add (rather than overwrite) a custom-config-file block -->
    <custom-config-file target="AndroidManifest.xml" parent="./" mode="add">
        <application android:name="customApplication"></application>
    </custom-config-file>
    
</platform>

iOS

  • The plugin currently supports custom configuration of:
    • the project plist (*-Info.plist) using <custom-config-file> blocks
    • build settings using <custom-preference> elements
    • image asset catalogs using <custom-resource> elements
  • All iOS-specific config should be placed inside the <platform name="ios"> in config.xml.

iOS preferences

  • Preferences for iOS can be used to define build configuration settings
  • The plugin currently supports:
    • setting of XCBuildConfiguration block keys in the project.pbxproj file
    • xcodefunc as an interface to apply functions from node-xcode

XCBuildConfiguration

  • XCBuildConfiguration <custom-preference> elements are used to set preferences in the project settings file platforms/ios/{PROJECT_NAME}/{PROJECT_NAME}.xcodeproj/project.pbxproj

  • Currently, XCBuildConfiguration is the only supported block type.

  • However, there is no constraint on the list of keys for which values may be set.

  • If an entry already exists in an XCBuildConfiguration block for the specified key, the existing value will be overwritten with the specified value.

  • If no entry exists in any XCBuildConfiguration block for the specified key, a new key entry will be created in each XCBuildConfiguration block with the specified value.

  • By default, values will be applied to both "Release" and "Debug" XCBuildConfiguration blocks.

  • However, the block type can be specified by adding a buildType attribute to the <custom-preference> element in the config.xml: value is either debug or release

    • e.g <custom-preference name="ios-XCBuildConfiguration-IPHONEOS_DEPLOYMENT_TARGET" value="7.0" buildType="release" />
  • By default, both the key (preference name) and value will be quote-escaped when inserted into the XCBuildConfiguration block.

    • e.g. <custom-preference name="ios-XCBuildConfiguration-IPHONEOS_DEPLOYMENT_TARGET" value="7.0" buildType="release" />
    • will appear in project.pbxproj as: "IPHONEOS_DEPLOYMENT_TARGET" = "7.0";
  • The default quoting can be override by setting the quote attribute on the <custom-preference> element.

    • Valid values are:
      • "none" - don't quote key or value
      • "key" - quote key but not value
      • "value" - quote value but not key
      • "both" - quote both key and value
    • e.g. <custom-preference name="ios-XCBuildConfiguration-IPHONEOS_DEPLOYMENT_TARGET" value="7.0" buildType="release" quote="none" />
    • will appear in project.pbxproj as: IPHONEOS_DEPLOYMENT_TARGET = 7.0;
  • Preferences should be defined in the format <custom-preference name="ios-SOME_BLOCK_TYPE-SOME_KEY" value="SOME_VALUE" />

  • Therefore, the preference name should be prefixed with ios-XCBuildConfiguration, for example:

.xcconfig files
  • Cordova uses .xcconfig files in /platforms/ios/cordova/ to override Xcode project settings in project.pbxproj with build-type specific values.
    • build.xcconfig is overriden by settings in build-debug.xcconfig and build-release.xcconfig for the corresponding build type.
  • When applying a custom preference, the plugin will look for an existing entry in the .xcconfig file that corresponds to the buildType attribute.
    • If buildType attribute is "debug" or "release", the plugin will look in build-debug.xcconfig or build-release.xcconfig respectively.
    • If buildType is not specified or set to "none", the plugin will look in build.xcconfig.
  • By default, if an entry is found in the .xcconfig file which corresponds to the custom preference name in the config.xml, the value in the .xcconfig file will be overwritten with the value in the config.xml.
  • To prevent the plugin from overwriting the value of a specific preference in the corresponding .xcconfig file, set the preference attribute xcconfigEnforce="false".
    • e.g <custom-preference name="ios-XCBuildConfiguration-SOME_PREFERENCE" value="Some value" buildType="debug" xcconfigEnforce="false" />
  • If a preference value doesn't already exist in the corresponding .xcconfig file, you can force its addition by setting the preference attribute xcconfigEnforce="true". This will append it to the corresponding .xcconfig` file.
    • e.g <custom-preference name="ios-XCBuildConfiguration-SOME_PREFERENCE" value="Some value" buildType="debug" xcconfigEnforce="true" />
  • Dependencies on additional .xcconfig files be added to a project by using #include statements. Note, the buildType attribute applies as stated above, however, xcconfigEnforce has no effect on #include statements as it is possible to have multiple #include statemnets in a single .xcconfig file.
    • e.g. <custom-preference name="ios-XCBuildConfiguration-#INCLUDE" value="/path/to/external/dependency/additional_config.xcconfig" />.
  • A backup copy of any modified .xcconfig file will be made in 'plugins/cordova-custom-config/backup/ios'. By default, these backups will be restored prior to the next prepare operation.
  • Auto-restore of the backups can be disabled by setting <custom-preference name="cordova-custom-config-autorestore" value="false" /> in the config.xml.
  • Preference names and values will not be quote-escaped in .xcconfig files, so the quote attribute has no effect on them.
CODE_SIGN_IDENTITY preferences
  • Cordova places its default CODE_SIGN_IDENTITY for Release builds in build-release.xcconfig but for Debug builds in `build.xcconfig.
  • If you set a CODE_SIGN_IDENTITY preference in the config.xml with buildType="release", the plugin will overwrite the defaults in build-release.xcconfig.
    • e.g. <custom-preference name="ios-XCBuildConfiguration-CODE\_SIGN\_IDENTITY" value="iPhone Distribution: My Release Profile (A1B2C3D4)" buildType="release" />
  • If you set a CODE_SIGN_IDENTITY preference in the config.xml with buildType="debug", the plugin will overwrite the defaults in build.xcconfig.
    • e.g. <custom-preference name="ios-XCBuildConfiguration-CODE\_SIGN\_IDENTITY" value="iPhone Distribution: My Debug Profile (A1B2C3D4)" buildType="debug" />
  • You can prevent the CODE_SIGN_IDENTITY preferences being overwritten by setting xcconfigEnforce="false".
    • e.g. <custom-preference name="ios-XCBuildConfiguration-CODE\_SIGN\_IDENTITY" value="iPhone Distribution: My Release Profile (A1B2C3D4)" buildType="release" xcconfigEnforce="false" />
  • You can force the plugin to add a new entry for CODE_SIGN_IDENTITY preference with buildType="debug" to build-debug.xcconfig, rather than overwriting the defaults in build.xcconfig by setting xcconfigEnforce="true". This will still override the defaults in build.xcconfig, because build-debug.xcconfig overrides build.xcconfig.
    • e.g. <custom-preference name="ios-XCBuildConfiguration-CODE\_SIGN\_IDENTITY" value="iPhone Distribution: My Debug Profile (A1B2C3D4)" buildType="debug" xcconfigEnforce="true" />

xcodefunc

  • xcode-func preferences enable functions within node-xcode to be called to edit different block types (such as Sources, Resources or Frameworks) in the project.pbxproj.
  • The preference name should be ios-xcodefunc, i.e. name="ios-xcodefunc"
  • The function to call in node-xcode should be specified using the func attribute, e.g. func="addResourceFile"
  • Function arguments should be specified using <arg /> child elements. It supports the following attributes:
    • value- the value of the argument, e.g. value="src/content/image.png"
    • type - the type of the value, e.g. type="String".
      • Supported types are:
        • Null - evaluates to null
        • Undefined - evaluates to undefined
        • Object - a stringified JSON object that will be parsed back into its object form
        • Number - a Javascript Number
        • String - a Javascript String
        • Symbol - a Javascript Symbol
      • If type is not specified, the argument value will be passed exactly as defined in the value attribute
    • flag - a modifier for specific types of argument, e.g. flag="path"
      • Currently, the only supported value is path which forces the path to be resolved either as an absolute path or relative to the project root.

For example:

<custom-preference name="ios-xcodefunc" func="addResourceFile">
    <arg type="String" value="src/content/image.png" flag="path" />
</custom-preference>

will add resource image.png from ./src/content (i.e. ../../src/content/image.png relative to ./platforms/ios/)

iOS config blocks

  • <custom-config-file> elements are currently used to:
    • set preferences in the project .plist file (platforms/ios/{PROJECT_NAME}/{PROJECT_NAME}-Info.plist).
    • add to Precompiled Headers file (platforms/ios/{PROJECT_NAME}/{PROJECT_NAME}-Prefix.pch).
  • all <custom-config-file> elements should have the platform attribute set to ios: <custom-config-file platform="ios">

iOS project plist config blocks

  • the target attribute of the <custom-config-file> should be set to *-Info.plist: <custom-config-file platform="ios" target="*-Info.plist">

  • the parent attribute is used to determine which key name to use for the custom preference

    • e.g. <custom-config-file platform="ios" target="*-Info.plist" parent="NSLocationAlwaysUsageDescription">
    • will appear in {PROJECT_NAME}-Info.plist as <key>NSLocationAlwaysUsageDescription</key> under /plist/dict
  • the value of the preference is set by the child elements of the <custom-config-file> element. These will appear directly below the preference <key> in the .plist file.

    • For example:

      <custom-config-file platform="ios" target="*-Info.plist" parent="NSLocationAlwaysUsageDescription"> <string>This app requires constant access to your location in order to track your position, even when the screen is off.</string> </custom-config-file>

    • will appear in the plist file as:

      <key>NSLocationAlwaysUsageDescription</key> <string>This app requires constant access to your location in order to track your position, even when the screen is off.</string>

  • if the .plist value type is an array, by default the values in the <custom-config-file> block will be merged with any existing values.

    • For example, if the plist already contains:

      <key>LSApplicationQueriesSchemes</key> <array> <string>fbapi</string> <string>fb-messenger-api</string> </array>

    • Then adding the <custom-config-file> block:

      <custom-config-file parent="LSApplicationQueriesSchemes" target="*-Info.plist"> <array> <string>myapp</string> <string>myapp2</string> </array> </custom-config-file>

    • will result in the plist file as:

      <key>LSApplicationQueriesSchemes</key> <array> <string>fbapi</string> <string>fb-messenger-api</string> <string>myapp</string> <string>myapp2</string> </array>

  • this behaviour can also be explicitly specified by adding mode="merge" to the <custom-config-file> block:

    • For example, the <custom-config-file> block:

        `<custom-config-file parent="LSApplicationQueriesSchemes" target="*-Info.plist" mode="replace">
             <array>
                 <string>myapp</string>
                 <string>myapp2</string>
             </array>
        </custom-config-file>`
      
      • will also result in the plist file as:

        <key>LSApplicationQueriesSchemes</key> <array> <string>fbapi</string> <string>fb-messenger-api</string> <string>myapp</string> <string>myapp2</string> </array>

  • to replace existing values with those in the <custom-config-file> block, use the attribute mode="replace":

    • For example, if the plist already contains:

      <key>LSApplicationQueriesSchemes</key> <array> <string>fbapi</string> <string>fb-messenger-api</string> </array>

    • Then adding the <custom-config-file> block:

      <custom-config-file parent="LSApplicationQueriesSchemes" target="*-Info.plist" mode="replace"> <array> <string>myapp</string> <string>myapp2</string> </array> </custom-config-file>

      • will result in the plist file as:

        <key>LSApplicationQueriesSchemes</key> <array> <string>myapp</string> <string>myapp2</string> </array>

  • to delete existing values in the plist, specify the key to delete as the parent and use the attribute mode="delete":

    • For example, if the plist already contains:

      <key>LSApplicationQueriesSchemes</key> <array> <string>fbapi</string> <string>fb-messenger-api</string> </array>

    • Then adding the <custom-config-file> block:

      <custom-config-file parent="LSApplicationQueriesSchemes" target="*-Info.plist" mode="delete"/>

      • will result in the existing block being removed from the plist

iOS Precompile Header config blocks

  • the target attribute of the <custom-config-file> should be set to *-Prefix.pch: <custom-config-file platform="ios" target="*-Prefix.pch">

iOS image resources

Purpose:

  • Sometimes it can be necessary to create custom iOS image asset catalogs in Cordova-based iOS apps.
    • For example, some plugins require that custom images be present in a custom asset catalog in order to make use of them:
    • This could be done manually by editing the platform project in XCode, but this is fragile since platform projects are volatile.
      • i.e. can be removed when removing/updating the platform via Cordova CLI.
    • So this plugin provides a mechanism to automate the generation custom asset catalogs.

Usage:

  • Image asset catalogs can be defined using <custom-resource> elements

  • The <custom-resource> elements must be places inside of the <platform name="ios"> element

  • The <custom-resource> elements must have the attribute type="image": <custom-resource type="image" />

  • The src attribute (required) should specify the relative local path to the image file.

    • The relative root is the Cordova project root
    • e.g. <custom-resource src="resources/custom-catalog/[email protected]" />
      • where the image file is location in /path/to/project/root/resources/custom-catalog/[email protected]
  • The catalog attribute (required) specifies the name of the catalog to add the image to

    • e.g. <custom-resource catalog="custom-catalog"/>
  • The scale attribute (required) specifies the scale factor of the image

    • Valid values are: 1x, 2x, 3x
    • e.g. <custom-resource scale="1x"/>
  • The idiom attribute (optional) specifies the target device family

    • Valid values are:
      • universal - all devices
      • iphone - iPhones only
      • ipad - iPads only
      • watch - Apple Watch only
    • If not specified, defaults to universal
    • e.g. <custom-resource idiom="iphone"/>
  • Full example:

    <custom-resource type="image" src="resources/custom-catalog/[email protected]" catalog="custom-catalog" scale="1x" idiom="iphone" />

iOS example

config.xml:

<platform name="ios">

    <!-- Set ENABLE_BITCODE to YES in XCode project file override NO value in /ios/cordova/build.xcconfig -->
    <custom-preference name="ios-XCBuildConfiguration-ENABLE_BITCODE" value="YES" />

    <!-- Set deploy target SDKs for release and debug builds -->
    <custom-preference name="ios-XCBuildConfiguration-IPHONEOS_DEPLOYMENT_TARGET" value="9.1" buildType="debug" quote="none" />
    <custom-preference name="ios-XCBuildConfiguration-IPHONEOS_DEPLOYMENT_TARGET" value="7.0" buildType="release" />

    <!-- Custom code signing profiles (overriding those in /ios/cordova/*.xcconfig -->
    <custom-preference name="ios-XCBuildConfiguration-CODE\_SIGN\_IDENTITY" value="iPhone Developer: Dave Alden (8VUQ6DYDLL)" buildType="debug" xcconfigEnforce="true" />
    <custom-preference name="ios-XCBuildConfiguration-CODE\_SIGN\_IDENTITY[sdk=iphoneos*]" value="iPhone Developer: Dave Alden (8VUQ6DYDLL)" buildType="debug" />
    <custom-preference name="ios-XCBuildConfiguration-CODE\_SIGN\_IDENTITY[sdk=iphoneos9.1]" value="iPhone Developer: Dave Alden (8VUQ6DYDLL)" buildType="debug" />
    <custom-preference name="ios-XCBuildConfiguration-CODE\_SIGN\_IDENTITY" value="iPhone Distribution: Working Edge Ltd (556F3DRHUD)" buildType="release" xcconfigEnforce="false" />
    <custom-preference name="ios-XCBuildConfiguration-CODE\_SIGN\_IDENTITY[sdk=iphoneos*]" value="iPhone Distribution: Working Edge Ltd (556F3DRHUD)" buildType="release" />
    <custom-preference name="ios-XCBuildConfiguration-CODE\_SIGN\_IDENTITY[sdk=iphoneos9.1]" value="iPhone Distribution: Working Edge Ltd (556F3DRHUD)" buildType="release" />

    <!-- Add resource file by relative path -->
    <custom-preference name="ios-xcodefunc" func="addResourceFile">
        <arg type="String" value="src/content/image.png" flag="path" />
    </custom-preference>

   <!-- By default, merge with existing array values -->
   <custom-config-file parent="LSApplicationQueriesSchemes" target="*-Info.plist">
       <array>
           <string>myapp</string>
           <string>myapp2</string>
           <string>myapp3</string>
       </array>
   </custom-config-file>

   <!-- Explicitly merge with existing array values -->
   <custom-config-file platform="ios" target="*-Info.plist" parent="UISupportedInterfaceOrientations" mode="merge" >
       <array>
           <string>UIInterfaceOrientationPortrait</string>
           <string>UIInterfaceOrientationPortraitUpsideDown</string>
       </array>
   </custom-config-file>

   <!-- Replace existing values -->
   <custom-config-file platform="ios" target="*-Info.plist" parent="UISupportedInterfaceOrientations~ipad" mode="replace">
       <array>
           <string>UIInterfaceOrientationPortrait</string>
           <string>UIInterfaceOrientationPortraitUpsideDown</string>
       </array>
   </custom-config-file>

    <!-- Set background location mode -->
    <custom-config-file platform="ios" target="*-Info.plist" parent="UIBackgroundModes">
        <array>
            <string>location</string>
        </array>
    </custom-config-file>

    <!-- Set message displayed when app requests constant location updates -->
    <custom-config-file platform="ios" target="*-Info.plist" parent="NSLocationAlwaysUsageDescription">
        <string>This app requires constant access to your location in order to track your position, even when the screen is off.</string>
    </custom-config-file>

    <!-- Set message displayed when app requests foreground location updates -->
    <custom-config-file platform="ios" target="*-Info.plist" parent="NSLocationWhenInUseUsageDescription">
        <string>This app will now only track your location when the screen is on and the app is displayed.</string>
    </custom-config-file>

    <!-- Allow arbitrary loading of resources over HTTP on iOS9 -->
    <custom-config-file platform="ios" target="*-Info.plist" parent="NSAppTransportSecurity">
        <dict>
            <key>NSAllowsArbitraryLoads</key>
            <true/>
        </dict>
    </custom-config-file>
    
    <!-- Custom image asset catalog -->
    <custom-resource type="image" catalog="custom" src="resources/ios/custom-icons/[email protected]" scale="1x" idiom="universal" />
    <custom-resource type="image" catalog="custom" src="resources/ios/custom-icons/[email protected]" scale="2x" idiom="universal" />
    <custom-resource type="image" catalog="custom" src="resources/ios/custom-icons/[email protected]" scale="3x" idiom="universal" />
</platform>

Plugin preferences

The plugin supports some preferences which are used to customise the behaviour of the plugin. These preferences should be placed at the top level (inside <widget>) rather than inside individual <platform> elements. Each preference name is prefixed with cordova-custom-config to avoid name clashes, for example:

<preference name="cordova-custom-config-autorestore" value="true" />

The following preferences are currently supported:

  • cordova-custom-config-autorestore - if true, the plugin will restore a backup of platform configuration files taken at plugin installation time. See the Removable preferences section for details. Defaults to false.
  • cordova-custom-config-stoponerror - if true and an error occurs while updating config for a given platform during a prepare operation, the error will cause the prepare operation to fail. If false, the plugin will log the error but will proceed and attempt to update any other platforms, before allowing the prepare operation to continue. Defaults to false.
  • cordova-custom-config-hook - determines which Cordova hook operation to use to run the plugin and apply custom config. Defaults to after_prepare if not specified. You may wish to change this to apply custom config earlier or later, for example if config applied by this plugin is clashing with other plugins. Possible values are: before_prepare, after_prepare, before_compile. See the Cordova hooks documentation for more on the Cordova build process.
  • cordova-custom-config-parse_unprefixed - determines whether the plugin should attempt to parse unprefixed custom config elements in config.xml
    • If not explicitly specified, the plugin will set a default by detecting whether the platform project is cordova-android@7 or cordova-android@6 (or below)
      • If cordova-android@6, defaults to true
      • If cordova-android@7, defaults to false

Log output

If you run the prepare operation with the --verbose command-line option, the plugin will output detail about the operations it's performing. Console messages are prefixed with cordova-custom-config: . For example:

cordova prepare ios --verbose

Example project

An example project illustrating use of this plugin can be found here: https://github.com/dpa99c/cordova-custom-config-example

TODO

See the TODO list for planned features/improvements.

Credits

Config update hook based on this hook by Diego Netto

License

================

The MIT License

Copyright (c) 2016 Working Edge Ltd.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

cordova-custom-config's People

Contributors

dpa99c avatar gitrubb avatar jasperkuperus avatar menjoy avatar mrinterweb avatar paulcote avatar pke avatar rafalzmuda avatar ritzlgrmft avatar spiderneo1 avatar superserg8 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cordova-custom-config's Issues

Preference code is run even though it's included in non-executing platform block

Developing in visual studio 2015 for both Android and iOS.

When building for Android only the preference in the iOS platform block is still run.
i.e.

<platform name="ios">
<preference name="ios-XCBuildConfiguration-ENABLE_BITCODE" value="NO" />`
<platform>

This does not seem to occur when it comes to configuration blocks.
When the update error occurs, compilation for android breaks.

<preference name="cordova-custom-config-stoponerror" value="false"/> does not seem to remedy the issue.

As far as I can tell , the reason why the error occurs is because the file does not exist on the currently executing system, and it executes fine when building for iOS specifically as then the plugin is executed and run remotely on our Mac-buildmachine.

So have i stumbled up on a bug or is this working as intended?

No write file AndroidManifest.xml in OS X 10.11.4 and node 5.10.1

Hi!,
The hook no write changes in file. I change the line:

fs.writeFileSync(targetFilePath, tempManifest.write({indent: 4}), 'utf-8');

to

fs.writeFileSync(targetFilePath, tempManifest.write({indent: 4}), 'utf-8', (err) => {if(err) throw err;});

and this work.
Regards

Not working with Cordova 5.0.0?

Hi there, I am probably missing something silly, but it does not appear to work for me.

I want to change the AndroidManifest.xml so in my config.xml file I added your Android example xml, and I set the namespace correctly in my widget element.

Nothing changes in the manifest after I run cordova prepare. Looking at the log, Running applyCustomConfig.js is never called.

I tested your example and it works, same machine, same Cordova CLI and same android platform...

add to a list of things in build preferences

right now you can set a value in build preferences, but when it comes to lists of things (ie header search paths) you overwrite the whole list with a flat value. it would be cool if we had a syntax for pushing an item to the list of it isn't present

ios-XCBuildConfiguration preference tag's default Quote setting triggers ignore error during build

By default an ios-XCBuildConfiguration preference tag without a quote attribute renders the key and value into xcconfig file surrounded by double quotes. For example, the preference

<preference name="ios-XCBuildConfiguration-ENABLE_BITCODE" value="NO"/>

renders this line in xcconfig

"ENABLE_BITCODE" = "NO"

For me (using platform cordova-ios 3.9.2), when building with cordova build ios --device this quoted entry throws an error (on build-debug.xcconfig):

Ignoring configuration file '/PATH_TO_CORDOVA_APP/platforms/ios/cordova/build-debug.xcconfig' because it could not be loaded.
  Reason: File could not be parsed due to an error: String '"ENABLE_BITCODE" = "NO"' could not be parsed: '"ENABLE_BITCODE"' is not a legal macro nameBuild settings from command line

Similarly, cordova build ios --release --device throws an error (on build-release.xcconfig):

Ignoring configuration file '/PATH_TO_CORDOVA_APP/platforms/ios/cordova/build-release.xcconfig' because it could not be loaded.
  Reason: File could not be parsed due to an error: String '"ENABLE_BITCODE" = "NO"' could not be parsed: '"ENABLE_BITCODE"' is not a legal macro nameBuild settings from command line

I was able to resolve my build issues by using the quote attribute in my preference in config.xml:

<preference name="ios-XCBuildConfiguration-ENABLE_BITCODE" value="NO" quote="none"/>

I believe quote="none" should be the default setting.

Version 1.1.5: setting ios preferences no longer works

I have been successfully using version 1.1.4 of this plugin to set the 2 ios preferences as shown below.
I just tried to update to the 1.1.5 version of the plugin and now neither of my preference settings are taking place (they don't end up in the platforms/ios/*.xcodeproj/project.pbxproject file).

<platform name="ios">
    <preference
        name="ios-XCBuildConfiguration-PRODUCT_NAME" value="'Mobile App'" />

    <preference
        name="ios-XCBuildConfiguration-IPHONEOS_DEPLOYMENT_TARGET" value="9.0" />

</platform>

Keep going if failed on xcode

We have two platform Android and iOS. But no every developer has mac so not every one has xcode installed. Therefore I suggest the plugin will keep working even if failed to find xcode module.

Thanks

indexBy issue

$ cordova prepare android
cordova-custom-config: Error updating config for platform 'android': _.indexBy is not a function
cordova-custom-config: Error updating config for platform 'ios': _.indexBy is not a function

$ cordova plugin remove cordova-custom-config
Uninstalling cordova-custom-config from android
Uninstalling cordova-custom-config from ios
Error: Expected "/* Begin ", "/* End ", """ or [A-Za-z0-9_.] but "<" found.

$ cordova plugin add cordova-custom-config
Fetching plugin "cordova-custom-config@~1.1.8" via npm
Installing "cordova-custom-config" for android
Installing "cordova-custom-config" for ios
Failed to install 'cordova-custom-config':undefined
Error: Expected "/* Begin ", "/* End ", """ or [A-Za-z0-9_.] but "<" found.

Any ideas?

Removing manifest elements

This looks like a good replacement for the phonegap-build equivalent but a quick read of your documentation shows no support for removing configuration elements. For example, to remove a bunch of permissions I would do in phonegap-build:

    <gap:config-file platform="android" parent="/manifest" mode="delete">
      <uses-permission android:name="android.permission.CAMERA"/>
      <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
      <uses-feature android:name="android.hardware.camera" android:required="false"/>
    </gap:config-file>

Could this be added?

Thank you.

iOS config-file entries not appearing in *-Info.plist

Using version 1.2.4 with [email protected]. Have added a few config-file entries to try and add/overwrite entries in our *-Info.plist file and they are not appearing. We even tried just using one of your examples. Here's the output on the console during $cordova prepare ios --verbose:

cordova-custom-config: Write to plist; key=NSLocationAlwaysUsageDescription; value='This app requires constant access to your location in order to track your position, even when the screen is off.'

However, when you look at the plist file you see that the entry was not added.

Add License to package.json

cordova displays a warning when using the plugin:

package.json cordova-custom-config@1.1.3 No license field.

You should add follwing field to avoid the warning:

"license": "MIT"

appears to be deleting project level package.json file

version 1.2.2

after running $cordova prepare ios --verbose you see these lines in the output near the end:

cordova-custom-config: Completed npm install
cordova-custom-config: Installed modules
cordova-custom-config: Removed our package.json
cordova-custom-config: Dependency resolution complete

Shortly thereafter you'll notice that your package.json file at the project level is missing. That's no good. I didn't see this happen before today.

Request - Add Team through custom configuration

I've setup my app to use automated code signing ( iOS Developer set for all fields ) so there is no need to use the code signing fields in custom configuration. Is there a way to automate the Team selection (General tab in Xcode) through this plugin?

Add localized entries to ios plist

Is there a way to add localized keys/strings to ios plist files with this plugin? Especially for the NSLocationWhenInUseUsageDescription

Plugin breaking Android and iOS version codes

When the plugin is installed, Android version code and iOS bundle version are not updated in the platforms from their values in config.xml

Widget element looks like this:

<widget android-versionCode="28" id="com.app.my" ios-CFBundleVersion="28" version="3.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:cdv="http://cordova.apache.org/ns/1.0">

With the plugin removed, values update correctly.

Missing xxx/platforms/ios/cordova/build-extras.xconfig

Hi.

Got a problem on iOS platform, don't really know if the problem is plugin related or cordova, but I take my chance here.

When I tried to install the plugin, it fails about missing some .xconfig file. Here are the logs :

platform add ios --verbose
cordova-custom-config: package.json already exists
cordova-custom-config: Copied existing package.json to package.json.tmp
cordova-custom-config: Copying package.json
cordova-custom-config: Copied package.json
cordova-custom-config: Installing plugin dependencies...
cordova-custom-config: Running npm install
cordova-custom-config: Completed npm install
cordova-custom-config: Installed modules
cordova-custom-config: package.json.tmp exists
cordova-custom-config: Overwrote our package.json with original package.json.tmp
cordova-custom-config: Removing package.json.tmp
cordova-custom-config: Removed package.json.tmp
cordova-custom-config: Dependency resolution complete
No version supplied. Retrieving version from config.xml...
Adding ios project...
Running command: /Users/thomas/.cordova/lib/npm_cache/cordova-ios/3.8.0/package/bin/create --cli /Users/thomas/dev/html/rando/platforms/ios com.latitude.rando Rando
iOS project created with [email protected]
Command finished with error code 0: /Users/thomas/.cordova/lib/npm_cache/cordova-ios/3.8.0/package/bin/create --cli,/Users/thomas/dev/html/rando/platforms/ios,com.latitude.rando,Rando
cordova-custom-config: Running restoreBackups.js
cordova-custom-config: package.json already exists
cordova-custom-config: Copied existing package.json to package.json.tmp
cordova-custom-config: Copying package.json
cordova-custom-config: Copied package.json
cordova-custom-config: Installing plugin dependencies...
cordova-custom-config: Running npm install
cordova-custom-config: Completed npm install
cordova-custom-config: Installed modules
cordova-custom-config: package.json.tmp exists
cordova-custom-config: Overwrote our package.json with original package.json.tmp
cordova-custom-config: Removing package.json.tmp
cordova-custom-config: Removed package.json.tmp
cordova-custom-config: Dependency resolution complete
cordova-custom-config: Checking to see if there are backups to restore...
cordova-custom-config: Restored backup of 'project.pbxproj' to :/Users/thomas/Dev/html/rando/platforms/ios/Rando.xcodeproj/project.pbxproj
cordova-custom-config: Finished restoring backups
Generating config.xml from defaults for platform "ios"
Calling plugman.prepare for platform "ios"
Preparing ios project
Processing configuration changes for plugins.
Iterating over installed plugins: []
Writing out cordova_plugins.js...
Wrote out iOS Bundle Identifier to "com.latitude.rando"
Wrote out iOS Bundle Version to "0.0.1"
Copying icon from /Users/thomas/dev/html/rando/resources/ios/icon/icon-60.png to /Users/thomas/dev/html/rando/platforms/ios/Rando/Resources/icons/icon-60.png
Copying icon from /Users/thomas/dev/html/rando/resources/ios/icon/[email protected] to /Users/thomas/dev/html/rando/platforms/ios/Rando/Resources/icons/[email protected]
Copying icon from /Users/thomas/dev/html/rando/resources/ios/icon/[email protected] to /Users/thomas/dev/html/rando/platforms/ios/Rando/Resources/icons/[email protected]
Copying icon from /Users/thomas/dev/html/rando/resources/ios/icon/icon-76.png to /Users/thomas/dev/html/rando/platforms/ios/Rando/Resources/icons/icon-76.png
Copying icon from /Users/thomas/dev/html/rando/resources/ios/icon/[email protected] to /Users/thomas/dev/html/rando/platforms/ios/Rando/Resources/icons/[email protected]
Copying icon from /Users/thomas/dev/html/rando/resources/ios/icon/icon-small.png to /Users/thomas/dev/html/rando/platforms/ios/Rando/Resources/icons/icon-small.png
Copying icon from /Users/thomas/dev/html/rando/resources/ios/icon/[email protected] to /Users/thomas/dev/html/rando/platforms/ios/Rando/Resources/icons/[email protected]
Copying icon from /Users/thomas/dev/html/rando/resources/ios/icon/icon-40.png to /Users/thomas/dev/html/rando/platforms/ios/Rando/Resources/icons/icon-40.png
Copying icon from /Users/thomas/dev/html/rando/resources/ios/icon/[email protected] to /Users/thomas/dev/html/rando/platforms/ios/Rando/Resources/icons/[email protected]
Copying icon from /Users/thomas/dev/html/rando/resources/ios/icon/icon.png to /Users/thomas/dev/html/rando/platforms/ios/Rando/Resources/icons/icon.png
Copying icon from /Users/thomas/dev/html/rando/resources/ios/icon/[email protected] to /Users/thomas/dev/html/rando/platforms/ios/Rando/Resources/icons/[email protected]
Copying icon from /Users/thomas/dev/html/rando/resources/ios/icon/icon-72.png to /Users/thomas/dev/html/rando/platforms/ios/Rando/Resources/icons/icon-72.png
Copying icon from /Users/thomas/dev/html/rando/resources/ios/icon/[email protected] to /Users/thomas/dev/html/rando/platforms/ios/Rando/Resources/icons/[email protected]
Copying icon from /Users/thomas/dev/html/rando/resources/ios/icon/icon-50.png to /Users/thomas/dev/html/rando/platforms/ios/Rando/Resources/icons/icon-50.png
Copying icon from /Users/thomas/dev/html/rando/resources/ios/icon/[email protected] to /Users/thomas/dev/html/rando/platforms/ios/Rando/Resources/icons/[email protected]
Copying splash from /Users/thomas/dev/html/rando/resources/ios/splash/Default~iphone.png to /Users/thomas/dev/html/rando/platforms/ios/Rando/Resources/splash/Default~iphone.png
Copying splash from /Users/thomas/dev/html/rando/resources/ios/splash/Default@2x~iphone.png to /Users/thomas/dev/html/rando/platforms/ios/Rando/Resources/splash/Default@2x~iphone.png
Copying splash from /Users/thomas/dev/html/rando/resources/ios/splash/Default-Portrait~ipad.png to /Users/thomas/dev/html/rando/platforms/ios/Rando/Resources/splash/Default-Portrait~ipad.png
Copying splash from /Users/thomas/dev/html/rando/resources/ios/splash/Default-Portrait@2x~ipad.png to /Users/thomas/dev/html/rando/platforms/ios/Rando/Resources/splash/Default-Portrait@2x~ipad.png
Copying splash from /Users/thomas/dev/html/rando/resources/ios/splash/Default-Landscape~ipad.png to /Users/thomas/dev/html/rando/platforms/ios/Rando/Resources/splash/Default-Landscape~ipad.png
Copying splash from /Users/thomas/dev/html/rando/resources/ios/splash/Default-Landscape@2x~ipad.png to /Users/thomas/dev/html/rando/platforms/ios/Rando/Resources/splash/Default-Landscape@2x~ipad.png
Copying splash from /Users/thomas/dev/html/rando/resources/ios/splash/Default-568h@2x~iphone.png to /Users/thomas/dev/html/rando/platforms/ios/Rando/Resources/splash/Default-568h@2x~iphone.png
Copying splash from /Users/thomas/dev/html/rando/resources/ios/splash/Default-667h.png to /Users/thomas/dev/html/rando/platforms/ios/Rando/Resources/splash/Default-667h.png
Copying splash from /Users/thomas/dev/html/rando/resources/ios/splash/Default-736h.png to /Users/thomas/dev/html/rando/platforms/ios/Rando/Resources/splash/Default-736h.png
Copying splash from /Users/thomas/dev/html/rando/resources/ios/splash/Default-Landscape-736h.png to /Users/thomas/dev/html/rando/platforms/ios/Rando/Resources/splash/Default-Landscape-736h.png
iOS Product Name has not changed (still "Rando")
Running command: /Users/thomas/dev/html/rando/hooks/after_prepare/010_add_platform_class.js /Users/thomas/dev/html/rando
add to body class: platform-ios
Command finished with error code 0: /Users/thomas/dev/html/rando/hooks/after_prepare/010_add_platform_class.js /Users/thomas/dev/html/rando
cordova-custom-config: Running applyCustomConfig.js
cordova-custom-config: package.json already exists
cordova-custom-config: Copied existing package.json to package.json.tmp
cordova-custom-config: Copying package.json
cordova-custom-config: Copied package.json
cordova-custom-config: Installing plugin dependencies...
cordova-custom-config: Running npm install
cordova-custom-config: Completed npm install
cordova-custom-config: Installed modules
cordova-custom-config: package.json.tmp exists
cordova-custom-config: Overwrote our package.json with original package.json.tmp
cordova-custom-config: Removing package.json.tmp
cordova-custom-config: Removed package.json.tmp
cordova-custom-config: Dependency resolution complete
cordova-custom-config: Backup exists for 'project.pbxproj' at: /Users/thomas/Dev/html/rando/plugins/cordova-custom-config/backup/ios/project.pbxproj
cordova-custom-config: Applied custom config from config.xml to /Users/thomas/dev/html/rando/platforms/ios/Rando.xcodeproj/project.pbxproj
cordova-custom-config: Reading build.xcconfig
cordova-custom-config: Reading build-extras.xcconfig
cordova-custom-config: Error updating config for platform 'ios': ENOENT: no such file or directory, open '/Users/thomas/dev/html/rando/platforms/ios/cordova/build-extras.xcconfig'
undefined

Any idea of the problem ?

Thanks !

Installing plugin fails

C:\dev\code\tippy-app>cordova plugin add cordova-custom-config
Fetching plugin "cordova-custom-config" via npm
Installing "cordova-custom-config" for android
cordova-custom-config: Installing plugin dependencies...
Running command: "C:\Program Files\nodejs\node.exe" C:\dev\code\tippy-app\hooks\after_plugin_add\010_register_plugin.js C:\dev\code\tippy-app
Running command: "C:\Program Files\nodejs\node.exe" C:\dev\code\tippy-app\hooks\after_plugin_add\register_plugins.js C:\dev\code\tippy-app
C:\dev\code\tippy-app\hooks\after_plugin_add\register_plugins.js:12
if (! _.contains(packageJSON.cordovaPlugins, plugin)) {
^

TypeError: _.contains is not a function
at C:\dev\code\tippy-app\hooks\after_plugin_add\register_plugins.js:12:11
at arrayEach (C:\dev\code\tippy-app\node_modules\lodash\lodash.js:474:11)
at Function.forEach (C:\dev\code\tippy-app\node_modules\lodash\lodash.js:7633:11)
at Object. (C:\dev\code\tippy-app\hooks\after_plugin_add\register_plugins.js:11:3)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Function.Module.runMain (module.js:447:10)
at startup (node.js:140:18)
Error: Hook failed with error code 1: C:\dev\code\tippy-app\hooks\after_plugin_add\register_plugins.js

Error : cordova-custom-config: Error updating config for platform 'android': undefined is not a function

Using your example project
While trying to run cordova prepare android --verbose I always get the below error

My Cordova veriosn 5.0.0

TypeError: undefined is not a function
at getConfigFilesByTargetAndParent (/home/mostafa/workspace/cordova-custom-config-example/plugins/cordova-custom-config/hooks/applyCustomConfig.js:100:19)
at parseConfigFiles (/home/mostafa/workspace/cordova-custom-config-example/plugins/cordova-custom-config/hooks/applyCustomConfig.js:201:27)
at parseConfigXml (/home/mostafa/workspace/cordova-custom-config-example/plugins/cordova-custom-config/hooks/applyCustomConfig.js:114:9)
at updatePlatformConfig (/home/mostafa/workspace/cordova-custom-config-example/plugins/cordova-custom-config/hooks/applyCustomConfig.js:431:26)
at /home/mostafa/workspace/cordova-custom-config-example/plugins/cordova-custom-config/hooks/applyCustomConfig.js:486:17
at arrayEach (/home/mostafa/node_modules/lodash/lodash.js:446:11)
at Function.forEach (/home/mostafa/node_modules/lodash/lodash.js:7482:11)
at applyCustomConfig.init (/home/mostafa/workspace/cordova-custom-config-example/plugins/cordova-custom-config/hooks/applyCustomConfig.js:483:11)
at /home/mostafa/workspace/cordova-custom-config-example/plugins/cordova-custom-config/hooks/resolveDependencies.js:46:11
at installRequiredNodeModules (/home/mostafa/workspace/cordova-custom-config-example/plugins/cordova-custom-config/hooks/resolveDependencies.js:109:7)

May you help on that?

Cannot override minSdkVersion on android manifest

I've moved from Phonegap Build 5.2.0 to 6.1.0, then it started to ignore my preferences and generate minSdkVersion 15+, my preferences were:

<preference name="android-minSdkVersion" value="21" />
<preference name="android-targetSdkVersion" value="23" />

I tried to use this plugin to overwrite sdk version on manifest but it's not working, I've tried both:

<preference name="android-manifest/uses-sdk/@android:minSdkVersion" value="21" />
<preference name="android-manifest/uses-sdk/@android:targetSdkVersion" value="23" />

and

<config-file target="AndroidManifest.xml" parent="/*">
    <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="23" />
</config-file>

without success.

Any thoughts on this?

Build error when following example in readme: No resource found that matches the given name (at 'value' with value '@android:style/Theme.Red.NoTitleBar')

I'm trying to get this plugin working with the ultimate goal of changing the theme to Material Dark on Android. I started by trying to change the theme to the one used in your example config.xml, but I get the following build error:

:processDebugResources/Users/sarah/Development/myapp/platforms/android/res/xml/config.xml:21:84-119 : AAPT: No resource found that matches the given name (at 'value' with value '@android:style/Theme.Red.NoTitleBar')

I incorporated the items from your readme one at a time, and I was able to build and run my app successfully after making the following two:

  1. Adding the Android namespace attribute. Mine now looks like this:
<widget 
    id="com.asdfasdfasdf.myapp" 
    version="2.0.2" 
    xmlns="http://www.w3.org/ns/widgets" 
    xmlns:cdv="http://cordova.apache.org/ns/1.0" 
    xmlns:android="http://schemas.android.com/apk/res/android"
    >

  1. I added the autorestore setting as per your instructions. Like so:
<widget 
    id="com.bla.myapp" 
    version="2.0.2" 
    xmlns="http://www.w3.org/ns/widgets" 
    xmlns:cdv="http://cordova.apache.org/ns/1.0" 
    xmlns:android="http://schemas.android.com/apk/res/android"
    >
    <name>bla</name>
    <description>
        Bla
    </description>
    <author email="[email protected]" href="http://www.bla.com">
        bla
    </author>
    <content src="index.html" />

    <!-- from https://github.com/dpa99c/cordova-custom-config#removable-preferences-via-backuprestore -->
    <preference name="cordova-custom-config-autorestore" value="true" />

    <preference name="android-minSdkVersion" value="19" />
    ...

Once everything built and ran properly with those changes, I added one of the lines from your Android example to my config.xml. Here's the entire Android section of config.xml:

<platform name="android">

        <preference name="android-manifest/application/activity/@android:theme" value="@android:style/Theme.Red.NoTitleBar" />

        <allow-intent href="market:*" />
        <icon src="www/res/icon/android/icon_48_mdpi.png" density="ldpi" />
        <icon src="www/res/icon/android/icon_48_mdpi.png" density="mdpi" />
        <icon src="www/res/icon/android/icon_72_hdpi.png" density="hdpi" />
        <icon src="www/res/icon/android/icon_96_xhdpi.png" density="xhdpi" />
        <icon src="www/res/icon/android/icon_144_xxhdpi.png" density="xxhdpi" />
        <icon src="www/res/icon/android/icon_192_xxxhdpi.png" density="xxxhdpi" />

</platform>


After adding that, building gives me the error I mentioned above:

:processDebugResources/Users/sarah/Development/myapp/platforms/android/res/xml/config.xml:21:84-119 : AAPT: No resource found that matches the given name (at 'value' with value '@android:style/Theme.Red.NoTitleBar')

Can you point me in the right direction? I'm not sure what I'm doing wrong. I'm running on a Nexus 6P with Android Marshmallow. Cordova is 6.2.0 and the Android platform version is 5.1.1.

Also, thank you for making this plugin! It looks excellent and well documented, and I look forward to getting it working. =)

Optimize hook names for setup and removal

Hi Dave,

what about using the special hooknames 'before_plugin_install' and 'before_plugin_uninstall' for setup/removal of your plugin? (see http://cordova.apache.org/docs/en/5.1.1/guide/appdev/hooks/)

Currently you are using 'before_plugin_rm' and 'after_plugin_add'. These will fire each time any plugin is added/removed.

The hooks names mentioned above should only fire, when your plugin is added or removed. This could have massive perfomance impacts on your users cordova build process.

Remove ./backup/platform/* on platform remove/update

I recently upgraded my Cordova project from Android 4.1.1 to Android 5.1.1.

I performed a "cordova platform remove android" and shortly after, I added back the platform with the new android version.

Upon building the project I noticed my AndroidManfiest.xml was still pointing to the old targetSDK. I couldn't figure out why. As it turns out, this plugin had a backup of the old Android Manifest. I'm not sure how you are maintaining this backup, but it should be removed anytime the platform is removed. (and probably updated as well?)

I did see the preference, cordova-custom-config-autorestore, which I will implement, but I wanted to at least report this.

indexBy renamed in lodash 4.0.0

The package.json doesn't specify a version for lodash, so when lodash was updated to 4.0.0 yesterday this plugin broke since the function "indexBy" was renamed "keyBy".

`keyBy` is not a function

Lodash seems to move fast. I get the following error.

cordova-custom-config: Error updating config for platform 'android': keyBy is not a function

What would be the best fix for this?

Error: Cannot find module 'elementtree'

Adding android project...
Creating Cordova project for the Android platform:
Path: platforms\android
Package: co.centure.mobile
Name: CNATURE
Activity: MainActivity
Android target: android-22
Copying template files...
Android project created with [email protected]
Error: Cannot find module 'elementtree'
at Function.Module._resolveFilename (module.js:337:15)
at Function.Module._load (module.js:287:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object. (C:\Users\oak\git\centure\centure-app\beethoven\plugin s\cordova-custom-config\hooks\fileUtils.js:7:10)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:311:12)
at Module.require (module.js:366:17)

Merging existing configs / tags / attributes

I am currently trying to just set one additional attribute for the <appliction> config.

That attribute is android:name="MainApp". However:

    <config-file target="AndroidManifest.xml">
        <application android:name="MainApplication" />
    </config-file>

causes the build to replace the whole application tag.

Is there a possibility to let the build process merge this attribute into the existing config?

Cocoon iOS Config XML Corruption

When I install the plugin into my Cocoon project, without even making any config.xml changes, the app loses its icon, splash screen and orientation. Those are just a few observations; I'm assuming it's completely ignoring all XML.

I've tried so many tests to get around this and now out of options.

Any ideas at all?

Thanks,

Malc

Android build will also trigger *-Info.plist change

I have this

<platform name="ios">
        <config-file overwrite="true" parent="UISupportedInterfaceOrientations" target="*-Info.plist" platform="ios">
            <array>
                <string>UIInterfaceOrientationPortrait</string>
            </array>
        </config-file>
        <config-file overwrite="true" parent="UISupportedInterfaceOrientations~ipad" target="*-Info.plist" platform="ios">
            <array>
                <string>UIInterfaceOrientationPortrait</string>
            </array>
        </config-file>

in my config.xml. When building an android version thought, this happens:

$ cordova build android --release
cordova-custom-config: Applied custom config from config.xml to xxx\platforms\ios\xxx\xxx-Info.plist

This doesn't seem to be right.

add in sugar for escaping

Example where this currently breaks:

<preference name="ios-XCBuildConfiguration-LD_RUNPATH_SEARCH_PATHS" value="@executable_path/Frameworks" />

needs to be changed to

<preference name="ios-XCBuildConfiguration-LD_RUNPATH_SEARCH_PATHS" value="&quot;@executable_path/Frameworks&quot;" />

or else it corrupts the pbxproj file

1.2.4 overwriting project-level package.json file

Greetings again. Our application grabbed your 1.2.4 update and we noticed that when it ran it overwrote our project-level package.json file. Is this something that happened with 1.2.4 or is it more of a timing issue?

Error parsing XML: unbound prefix when doing cordova build android

Hi,
Thanks for making this plugin. I really need this functionality. Unfortunately it breaks my cordova android build with this error:
../platforms/android/build/intermediates/res/armv7/debug/xml/config.xml:43: error: Error parsing XML: unbound prefix

That line says:
<config-file parent="/*" target="AndroidManifest.xml"> <uses-permission android:name="android.permission.CAMERA" /> </config-file>

The root config.xml file used by this installation has the following config platform settings that are used by your plugin:
<platform name="android"> <config-file target="AndroidManifest.xml" parent="/*"> <uses-permission android:name="android.permission.CAMERA" /> </config-file> <preference name="android-manifest/application/@android:name" value="com.joustie.foo.App" /> <icon src="resources/android/icon/drawable-ldpi-icon.png" density="ldpi"/> <icon src="resources/android/icon/drawable-mdpi-icon.png" density="mdpi"/> <icon src="resources/android/icon/drawable-hdpi-icon.png" density="hdpi"/> <icon src="resources/android/icon/drawable-xhdpi-icon.png" density="xhdpi"/> <icon src="resources/android/icon/drawable-xxhdpi-icon.png" density="xxhdpi"/> <icon src="resources/android/icon/drawable-xxxhdpi-icon.png" density="xxxhdpi"/> <splash src="resources/android/splash/drawable-land-ldpi-screen.png" density="land-ldpi"/> <splash src="resources/android/splash/drawable-land-mdpi-screen.png" density="land-mdpi"/> <splash src="resources/android/splash/drawable-land-hdpi-screen.png" density="land-hdpi"/> <splash src="resources/android/splash/drawable-land-xhdpi-screen.png" density="land-xhdpi"/> <splash src="resources/android/splash/drawable-land-xxhdpi-screen.png" density="land-xxhdpi"/> <splash src="resources/android/splash/drawable-land-xxxhdpi-screen.png" density="land-xxxhdpi"/> <splash src="resources/android/splash/drawable-port-ldpi-screen.png" density="port-ldpi"/> <splash src="resources/android/splash/drawable-port-mdpi-screen.png" density="port-mdpi"/> <splash src="resources/android/splash/drawable-port-hdpi-screen.png" density="port-hdpi"/> <splash src="resources/android/splash/drawable-port-xhdpi-screen.png" density="port-xhdpi"/> <splash src="resources/android/splash/drawable-port-xxhdpi-screen.png" density="port-xxhdpi"/> <splash src="resources/android/splash/drawable-port-xxxhdpi-screen.png" density="port-xxxhdpi"/> </platform>

Any idea why android build fails? The AndroidManifest.xml file int he platform directory is correctly updated by your plugin code, but it seems to also alter an 'intermediate' file that is parsed in the android build phase?

Advanced documentation on preference formatting

Very nice job, I am glad this plugin exists. :)

I can't find an easy way to map a field I want to modify to its name in the .plist for iOS.
For example, how can I access CFBundleDevelopmentRegion or CFBundleDisplayName ?

Thanks, and keep up the good work!

duplicated entry in generated AndroidManifest.xml

with this config:

<config-file parent="/*" target="AndroidManifest.xml">
            <uses-permission android:name="android.permission.CAMERA" />
            <uses-feature android:name="android.hardware.camera" />
            <uses-feature android:name="android.hardware.camera.autofocus" />
        </config-file>

generated file AndroidManifest.xml contains twice android.hardware.camera.autofocus but not android.hardware.camera

android:name="CordovaApp" vs. android:name="MainActivity"

Thank you for this great plugin.

With (the newest) Cordova CLI 5.3.1 and Cordova-Android 4.1.0 some preferences are not applied to the android manifest. We tracked this down to the following root cause:

In https://github.com/dpa99c/cordova-custom-config/blob/master/hooks/applyCustomConfig.js#L30 and the following lines you assume android:name="CordovaApp", but the cordova guys renamed the activity to 'MainActivity'.

This issue may be relevant for cli users only, I haven't tried to reproduce it on phonegap build service. The provided code changes should work with cli and pgb.

To support both activity names you could apply the following changes to your code:

  1. Change the android mapping config property "parent" from String to Array of String. This way you are able to provide alternative xpaths to resolve the parent.
    /*  Global object that defines the available custom preferences for each platform.
     Maps a config.xml preference to a specific target file, parent elements (first match will be used), and destination attribute or element
     */
    var preferenceMappingData = {
        'android': {
            'android-manifest-hardwareAccelerated': {target: 'AndroidManifest.xml', parent: ['./'], destination: 'android:hardwareAccelerated'},
            'android-installLocation': {target: 'AndroidManifest.xml', parent: ['./'], destination: 'android:installLocation'},
            'android-activity-hardwareAccelerated': {target: 'AndroidManifest.xml', parent: ['application'], destination: 'android:hardwareAccelerated'},
            'android-configChanges': {target: 'AndroidManifest.xml', parent: ['application/activity[@android:name=\'CordovaApp\']', 'application/activity[@android:name=\'MainActivity\']'], destination: 'android:configChanges'},
            'android-launchMode': {target: 'AndroidManifest.xml', parent: ['application/activity[@android:name=\'CordovaApp\']', 'application/activity[@android:name=\'MainActivity\']'], destination: 'android:launchMode'},
            'android-theme': {target: 'AndroidManifest.xml', parent: ['application/activity[@android:name=\'CordovaApp\']', 'application/activity[@android:name=\'MainActivity\']'], destination: 'android:theme'},
            'android-windowSoftInputMode': {target: 'AndroidManifest.xml', parent: ['application/activity[@android:name=\'CordovaApp\']', 'application/activity[@android:name=\'MainActivity\']'], destination: 'android:windowSoftInputMode'}
        },
        'ios': {}
    };
  1. Iterate of the alternative parents and use the first match:
    function updateAndroidManifest(targetFilePath, configItems) {
        var tempManifest = fileUtils.parseElementtreeSync(targetFilePath),
            root = tempManifest.getroot();

        _.each(configItems, function (item) {
            // if parent is not found on the root, child/grandchild nodes are searched
            var parentEl,
                data = item.data,
                childSelector = item.destination,
                childEl;

            _.each(item.parent, function(parentSelector){
                if(parentEl)
                    return;
                parentEl = root.find(parentSelector) || root.find('*/' + parentSelector);
            });

            if(!parentEl) {
                return;
            }

            if(item.type === 'preference') {
                parentEl.attrib[childSelector] = data.attrib['value'];
            } else {
                // since there can be multiple uses-permission elements, we need to select them by unique name
                if(childSelector === 'uses-permission') {
                    childSelector += '[@android:name=\'' + data.attrib['android:name'] + '\']';
                }

                childEl = parentEl.find(childSelector);
                // if child element doesnt exist, create new element
                if(!childEl) {
                    childEl = new et.Element(item.destination);
                    parentEl.append(childEl);
                }

                // copy all config.xml data except for the generated _id property
                _.each(data, function (prop, propName) {
                    if(propName !== '_id') {
                        childEl[propName] = prop;
                    }
                });
            }
        });
        fs.writeFileSync(targetFilePath, tempManifest.write({indent: 4}), 'utf-8');
    }

That's it. Now your plugin supports 'old' and 'new' activity names.

Sorry for not providing a pull request for this, but I'm a litlle in hurry these days.

Felix

ios-XCBuildConfiguration-CODE_SIGN_IDENTITY not respecting buildType attribute in latest versions of cordova-ios platform

In platform cordova-ios v4.0+, build.xcconfig already contains Developer entries for CODE_SIGN_IDENTITY which get incorrectly clobbered by custom configuration tags with buildType="release".

While I haven't encountered broken builds from this behavior, I get very nervous when the value iPhone Developer in build.xcconfig gets clobbered by my distribution code sign identity value. I expect my distribution code sign identify string to be added only to build-release.xcconfig. I expect my developer code sign identity string (set by a buildType="debug" preference) to be what is added to build.xcconfig (I think? Or would it make more sense for the value in build.xcconfig be removed and moved to build-debug.xcconfig?). I wonder if this behavior where buildType="release" preferences are getting applied to both build-release.xcconfig and build.xcconfig for any other XCBuildConfiguration keys?

cordova-ios v4.0 build.xcconfig and build-release.xcconfig
https://github.com/apache/cordova-ios/blob/4.0.0/bin/templates/scripts/cordova/build.xcconfig
https://github.com/apache/cordova-ios/blob/master/bin/templates/scripts/cordova/build-release.xcconfig


build.xcconfig before cordova prepare ios --release --device:

CODE_SIGN_IDENTITY = iPhone Developer
CODE_SIGN_IDENTITY[sdk=iphoneos*] = iPhone Developer

config.xml:

<preference name="ios-XCBuildConfiguration-CODE_SIGN_IDENTITY" value="iPhone Developer" buildType="debug" quote="none"/>
<preference name="ios-XCBuildConfiguration-CODE_SIGN_IDENTITY" value="iPhone Distribution: {{MY_DISTIBUTION_CODE_SIGN_IDENTITY}}" buildType="release" quote="none"/>

build.xcconfig after cordova prepare ios --release --device:

CODE_SIGN_IDENTITY = iPhone Distribution: {{MY_DISTIBUTION_CODE_SIGN_IDENTITY}}
CODE_SIGN_IDENTITY[sdk=iphoneos*] = iPhone Developer

build-release.xcconfig before cordova prepare ios --release --device:

CODE_SIGN_IDENTITY = iPhone Distribution
CODE_SIGN_IDENTITY[sdk=iphoneos*] = iPhone Distribution

config.xml:

<preference name="ios-XCBuildConfiguration-CODE_SIGN_IDENTITY" value="iPhone Developer" buildType="debug" quote="none"/>
<preference name="ios-XCBuildConfiguration-CODE_SIGN_IDENTITY" value="iPhone Distribution: {{MY_DISTIBUTION_CODE_SIGN_IDENTITY}}" buildType="release" quote="none"/>

build-release.xcconfig after cordova prepare ios --release --device:

CODE_SIGN_IDENTITY = iPhone Distribution: {{MY_DISTIBUTION_CODE_SIGN_IDENTITY}}
CODE_SIGN_IDENTITY[sdk=iphoneos*] = iPhone Developer

[FEATURE] Allow modifying other files than AndroidManifest.xml

I was very happy to find this plugin, but I'd like to add resources in res/values/strings.xml.
Could it be allowed?
Well, that part isn't hard: there is a check for the filename to be 'AndroidManifest.xml', which can be removed.

However, the object PLATFORM_CONFIG_FILES's contents would need to be determined either by looking at the backup directory's contents, or the list of modified files in config.xml.

Here is the diff of the changes I made in order for it to work for one extra file:
cordova-custom-config-additionalfile.txt

Version 1.1.6 is breaking android builds

Hi @dpa99c,

The version 1.1.6 is breaking the android builds for us. The error we get is:

/var/lib/jenkins/jobs/Mobile-App-Build/workspace/Cordova/plugins/cordova-custom-config/hooks/applyCustomConfig.js:396
st'), xcode = require('xcode'), tostr = require('tostr'), fileUtils = require(
                                                                    ^
ReferenceError: fileUtils is not defined
    at applyCustomConfig.init (/var/lib/jenkins/jobs/Mobile-App-Build/workspace/Cordova/plugins/cordova-custom-config/hooks/applyCustomConfig.js:400:79)

Any idea why?

AndroidManifest.xml not overwritten by the custom config

Hello ๐Ÿ˜ƒ

In the config.xml I have this custom config to change supports-screens inside the AndroidManifest.xml

    <platform name="android">
        [.... more code]
        <config-file target="AndroidManifest.xml" parent="/*">
            <supports-screens android:smallScreens="false"
                              android:normalScreens="false"
                              android:largeScreens="true"
                              android:xlargeScreens="true"
                              android:requiresSmallestWidthDp="600" />
        </config-file>
    </platform>

after each cordova prepare I still have the default value and the custom one is every time added as well

<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />

[.... more code]


<supports-screens android:largeScreens="true" android:normalScreens="false" android:requiresSmallestWidthDp="600" android:smallScreens="false" android:xlargeScreens="true" />
<supports-screens android:largeScreens="true" android:normalScreens="false" android:requiresSmallestWidthDp="600" android:smallScreens="false" android:xlargeScreens="true" />

Cannot build

I haven't build since 14 days, but today, I don't know why, nothing happens with a cordova build (android or ios) :

$ cordova build android
cordova-custom-config: Installing plugin dependencies...
cordova-custom-config: Skipping auto-restore of config file backup(s) due to config.xml preference
$

I have the problem on 3 different computers (each was able to build 14 days ago), and if I remove cordova-custom-config plugin, it works again. Maybe a problem with the new cordova-android or cordova-ios ?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.