cordova-config-utils
This hook can update platform configuration files based on preferences and config-file data defined in your normal config.xml, that are normally not used/ignored by Cordova. Use-cases include e.g. on iOS setting ENABLE_BITCODE = NO
or disabling Application Transport Security (ATS). Currently only the AndroidManifest.xml
, iOS *-Info.plist
and *.xcodeproj/project.pbxproj
files are supported.
Based off this awesome hook from Diego Netto, thanks!
Install
npm install cordova-config-utils
After install an after_prepare
folder will be added to your hooks
folder with the 011_update_config.js
script in it.
Usage
You can use <preference>
and <config-file>
tags:
Preferences
- Preferences defined outside of the platform element will apply to all platforms
- Preferences defined inside a platform element will apply only to the specified platform
- Platform preferences take precedence over common preferences
- The preferenceMappingData object contains all of the possible custom preferences to date including the target file they belong to, parent element, and destination element or attribute Config Files
Config-Files
- config-file elements MUST be defined inside a platform element, otherwise they will be ignored.
- config-file target attributes specify the target file to update. (AndroidManifest.xml or *-Info.plist)
- 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.
- config-file elements are uniquely indexed by target AND parent for each platform.
- If there are multiple config-file's defined with the same target AND parent, the last config-file will be used
- Elements defined WITHIN a config-file will replace or be appended to the same elements relative to the parent element
- If a unique config-file contains multiples of the same elements (other than uses-permssion elements which are selected by by the uses-permission name attribute), the last defined element will be retrieved.
Examples
Android
<!-- These preferences are actually available in Cordova by default although not currently documented --> <!-- Custom preferences examples -->
NOTE: For possible manifest values see http://developer.android.com/guide/topics/manifest/manifest-intro.html
iOS
NSAllowsArbitraryLoads
Notes
- Currently, items aren't removed from the platform config files if you remove them from config.xml. For example, if you add a custom permission, build, then remove it, it will still be in the manifest.
- If you make a mistake, for example adding an element to the wrong parent, you may need to remove and add your platform, or revert to your previous manifest/plist file.