Uploaded image for project: 'Apache Cordova'
  1. Apache Cordova
  2. CB-14108

<config-file> in config.xml increases config_munge count in ios.json and android.json.

    XMLWordPrintableJSON

    Details

      Description

      On both iOS and Android platforms, using <config-file> causes duplication in the `ios.json` and `android.json` files, which could lead to extremely large file sizes (and possibly unexpected behaviour?).

      For a Cordova 7.1/8.0 application, add the following to config.xml:

         <platform name="ios">
              <allow-intent href="itms:*" />
              <allow-intent href="itms-apps:*" />
              <config-file parent="NSCameraUsageDescription" target="*-Info.plist">
                  <string>Please permit Camera!</string>
              </config-file>
          </platform>
      

      Now run `cordova prepare`. The file `platforms/ios/ios.json` now contains the below. Note the count is 1.

       "config_munge": {
          "files": {
            "*-Info.plist": {
              "parents": {
                "NSCameraUsageDescription": [
                  {
                    "xml": "<string>Please permit Camera!</string>",
                    "count": 1
                  }
                ]
              }
            }
          }
        },
      

      Run `cordova prepare` again. The platforms/ios/ios.json changes, increasing the count to 2.

      "config_munge": {
          "files": {
            "*-Info.plist": {
              "parents": {
                "NSCameraUsageDescription": [
                  {
                    "xml": "<string>Please permit Camera!</string>",
                    "count": 2
                  }
                ]
              }
            }
          }
        },
      

      Furthermore, if we change the text inside the `<string>` in the `config.xml`:

          <platform name="ios">
              <allow-intent href="itms:*" />
              <allow-intent href="itms-apps:*" />
              <config-file parent="NSCameraUsageDescription" target="*-Info.plist">
                  <string>This app uses Camera!</string>
              </config-file>
          </platform>
      

      Then after running `cordova prepare`, there is now a second entry in `platforms/ios/ios.json`, rather than replacing the existing entry.

       "config_munge": {
          "files": {
            "*-Info.plist": {
              "parents": {
                "NSCameraUsageDescription": [
                  {
                    "xml": "<string>Please permit Camera!</string>",
                    "count": 2
                  },
                  {
                    "xml": "<string>This app uses Camera!</string>",
                    "count": 1
                  }
                ]
              }
            }
          }
        },
      
      

      This behaviour is the same for Android, and can be reproduced in the same way, by adding something like the below to `config.xml`:

          <platform name="android">
              <allow-intent href="market:*" />
              <config-file parent="/manifest" target="AndroidManifest.xml">
                  <uses-permission android:name="android.permission.VIBRATE" />
              </config-file>
          </platform>
      

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              knaito Ken Naito
            • Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Time Tracking

                Estimated:
                Original Estimate - Not Specified
                Not Specified
                Remaining:
                Remaining Estimate - 0h
                0h
                Logged:
                Time Spent - 20m
                20m