iOS
plist
Cordova
config.xml
mobile development

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:

xml
1<platform name="ios">
2    <edit-config file="*-Info.plist" mode="merge" target="NSCameraUsageDescription">
3        <string>This app needs camera access to scan codes.</string>
4    </edit-config>
5</platform>

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'
  • 'target is 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:

xml
1<platform name="ios">
2    <config-file platform="ios" target="*-Info.plist" parent="NSAppTransportSecurity">
3        <dict>
4            <key>NSAllowsArbitraryLoads</key>
5            <true/>
6        </dict>
7    </config-file>
8</platform>

That approach is more appropriate when the plist entry is not a single scalar value.

The rule of thumb is:

  • use edit-config when targeting a specific existing key cleanly
  • use config-file when 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.

xml
1<platform name="ios">
2    <config-file target="*-Info.plist" parent="CFBundleURLTypes">
3        <array>
4            <dict>
5                <key>CFBundleURLSchemes</key>
6                <array>
7                    <string>myapp</string>
8                </array>
9            </dict>
10        </array>
11    </config-file>
12</platform>

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.

bash
cordova prepare ios

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-config for direct key updates such as permission description strings.
  • Use config-file for nested plist structures such as arrays and dictionaries.
  • Rebuild or prepare the iOS platform after changing the config.
  • Verify the generated Info.plist so key paths and XML structure are correct.

Course illustration
Course illustration

All Rights Reserved.