[ 
https://issues.apache.org/jira/browse/CB-14108?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16494722#comment-16494722
 ] 

ASF GitHub Bot commented on CB-14108:
-------------------------------------

knight9999 opened a new pull request #24: CB-14108:
URL: https://github.com/apache/cordova-common/pull/24
 
 
   <!--
   Please make sure the checklist boxes are all checked before submitting the 
PR. The checklist
   is intended as a quick reference, for complete details please see our 
Contributor Guidelines:
   
   http://cordova.apache.org/contribute/contribute_guidelines.html
   
   Thanks!
   -->
   
   ### Platforms affected
   
   All Platforms
   
   ### What does this PR do?
   
   This PR affects the cordova prepare command as follows.
   1. Check the confliction of config-file tag in config.xml.
   2. Prevent unexpected increasing count in config_munge in platformJson 
(ios/ios.json or android/android.json).
   3. Removing unnecessary config_munge directive in platformJson after 
removing config-file tag.
   
   Futrher, adding related test codes. (ConfigError.spec.js, 
ConfigChanges.spec.js)
   
   ### What testing has been done on this change?
   
   Before this PR,  if we use config.file like
   
   ```
      <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>
   ```
   , then `cordova prepare` makes platforms/ios/ios.json 
   ```
    "config_munge": {
       "files": {
         "*-Info.plist": {
           "parents": {
             "NSCameraUsageDescription": [
               {
                 "xml": "<string>Please permit Camera!</string>",
                 "count": 1
               }
             ]
           }
         }
       }
     },
   ```
   note that count is 1. Again doing `cordova prepare` makes 
platforms/ios/ios.json
   ```
    "config_munge": {
       "files": {
         "*-Info.plist": {
           "parents": {
             "NSCameraUsageDescription": [
               {
                 "xml": "<string>Please permit Camera!</string>",
                 "count": 2
               }
             ]
           }
         }
       }
     },
   ```
   where the count is 2.
   Further if we remove config-file tag in config.xml, `cordova prepare` does 
not remove anything from  platforms/ios/ios.json.
   
   This unnatural behavior is fixed by this PR.
   
   
   ### Checklist
   - [x] [Reported an issue](http://cordova.apache.org/contribute/issues.html) 
in the JIRA database
   - [x] Commit message follows the format: "CB-3232: (android) Fix bug with 
resolving file paths", where CB-xxxx is the JIRA ID & "android" is the platform 
affected.
   - [x] Added automated test coverage as appropriate for this change.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


> <config-file> in config.xml increases config_munge count in ios.json and 
> android.json.
> --------------------------------------------------------------------------------------
>
>                 Key: CB-14108
>                 URL: https://issues.apache.org/jira/browse/CB-14108
>             Project: Apache Cordova
>          Issue Type: Bug
>          Components: cordova-common, cordova-lib
>    Affects Versions: 8.0.0
>            Reporter: Ken Naito
>            Priority: Major
>             Fix For: Master
>
>
> 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:
>  
> {code:java}
>    <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>
> {code}
> Now run `cordova prepare`. The file `platforms/ios/ios.json` now contains the 
> below. Note the count is 1.
>  
> {code:java}
>  "config_munge": {
>     "files": {
>       "*-Info.plist": {
>         "parents": {
>           "NSCameraUsageDescription": [
>             {
>               "xml": "<string>Please permit Camera!</string>",
>               "count": 1
>             }
>           ]
>         }
>       }
>     }
>   },
> {code}
> Run `cordova prepare` again. The platforms/ios/ios.json changes, increasing 
> the count to 2.
>   
> {code:java}
> "config_munge": {
>     "files": {
>       "*-Info.plist": {
>         "parents": {
>           "NSCameraUsageDescription": [
>             {
>               "xml": "<string>Please permit Camera!</string>",
>               "count": 2
>             }
>           ]
>         }
>       }
>     }
>   },
> {code}
> Furthermore, if we change the text inside the `<string>` in the `config.xml`:
> {code:java}
>     <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>
> {code}
> Then after running `cordova prepare`, there is now a second entry in 
> `platforms/ios/ios.json`, rather than replacing the existing entry.
>  
> {code:java}
>  "config_munge": {
>     "files": {
>       "*-Info.plist": {
>         "parents": {
>           "NSCameraUsageDescription": [
>             {
>               "xml": "<string>Please permit Camera!</string>",
>               "count": 2
>             },
>             {
>               "xml": "<string>This app uses Camera!</string>",
>               "count": 1
>             }
>           ]
>         }
>       }
>     }
>   },
> {code}
> This behaviour is the same for Android, and can be reproduced in the same 
> way, by adding something like the below to `config.xml`:
> {code:java}
>     <platform name="android">
>         <allow-intent href="market:*" />
>         <config-file parent="/manifest" target="AndroidManifest.xml">
>             <uses-permission android:name="android.permission.VIBRATE" />
>         </config-file>
>     </platform>
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscr...@cordova.apache.org
For additional commands, e-mail: issues-h...@cordova.apache.org

Reply via email to