Add entry to iOS .plist file via Cordova config.xml
Master System Design with Codemia
Enhance your system design skills with over 120 practice problems, detailed solutions, and hands-on exercises.
Introduction
In a Cordova project, you usually should not edit the generated iOS Info.plist by hand because platform files can be regenerated. The durable way to add plist entries is to declare them in config.xml so Cordova applies them during prepare and build steps.
Why config.xml Is the Right Place
Cordova treats the iOS project as generated output. If you open the Xcode project and change Info.plist directly, that change may disappear the next time the platform is re-added or rebuilt from clean state.
By putting the change in config.xml, you keep the configuration in source control and make it reproducible for every developer and CI build.
Typical plist changes added this way include:
- iOS permission usage descriptions
- custom URL schemes
- transport security settings
- background modes and platform-specific flags
Use edit-config for Direct Key Updates
For many common cases, edit-config is the clearest option. It lets you target a specific plist key and merge or overwrite its value.
A common example is adding a camera permission description:
When Cordova prepares the iOS platform, it writes that value into Info.plist.
The important pieces are:
- '
file="*-Info.plist"targets the generated iOS plist file' - '
targetis the plist key to modify' - '
mode="merge"tells Cordova to merge the entry into the existing file'
For simple string keys, this pattern is usually enough.
Use config-file for Nested Structures
Some plist settings are dictionaries or arrays rather than single string values. In those cases, config-file is often the better tool because it inserts XML under a chosen parent node.
A common example is adding transport security exceptions:
That approach is more appropriate when the plist entry is not a single scalar value.
The rule of thumb is:
- use
edit-configwhen targeting a specific existing key cleanly - use
config-filewhen inserting structured XML content under a parent node
Example: Add a URL Scheme
Custom URL schemes are another common need in hybrid mobile apps. That can also be expressed through config.xml.
After preparing the platform, the generated plist contains the correct URL-scheme structure without manual Xcode edits.
Verify the Generated Output
After changing config.xml, rebuild or re-prepare the iOS platform and inspect the generated plist to confirm the output.
Then verify in Xcode or inspect the generated file directly under the iOS platform directory. This matters because malformed XML or an incorrect parent path can cause the entry to be skipped or inserted incorrectly.
Common Pitfalls
A common mistake is editing Info.plist manually inside the generated iOS project and expecting the change to survive platform regeneration.
Another mistake is using the wrong Cordova tag. edit-config and config-file solve related but slightly different problems, and choosing the wrong one makes nested plist updates awkward.
People also often target the wrong key path or forget that plist structures are XML dictionaries and arrays, not arbitrary JSON-style objects.
Finally, be careful when multiple plugins also modify the plist. Conflicting edits to the same key can cause unexpected merges or build-time failures.
Summary
- Put iOS plist changes in Cordova
config.xml, not only in the generated Xcode project. - Use
edit-configfor direct key updates such as permission description strings. - Use
config-filefor nested plist structures such as arrays and dictionaries. - Rebuild or prepare the iOS platform after changing the config.
- Verify the generated
Info.plistso key paths and XML structure are correct.

