dpa99c / cordova-custom-config

Cordova/Phonegap plugin to update platform configuration files based on preferences and config-file data defined in config.xml
318 stars 84 forks source link

Error updating config for platform 'ios': Unexpected key "NSContactsUsageDescription" while parsing <dict/>. #132

Closed tobiasmuecksch closed 6 years ago

tobiasmuecksch commented 6 years ago

Hey there,

I'm currently experiencing the following error, when I try to add the iOS platform.

cordova-custom-config: Skipping auto-restore of config file backup(s)
cordova-custom-config: Applied custom config from config.xml to /Users/tmuecksch/Sites/myApp/platforms/ios/myApp/myApp-Info.plist
cordova-custom-config: Error updating config for platform 'ios': Unexpected key "NSContactsUsageDescription" while parsing <dict/>.

When I look at the myApp-Info.plist the file seems correctly assembled to me. But the build process doesn't finish correctly after this error message.

[ ... ]
        </dict>
      </dict>
      <key>NSAllowsArbitraryLoads</key>
      <true/>
    </dict>
    <key>UILaunchStoryboardName</key>
    <string>CDVLaunchScreen</string>
    <key>NSContactsUsageDescription</key>
    <string>displaying and syncing contacts</string>
  </dict>
</plist>

Versions

Since this error message is not helpful - what can I do to debug that error further?

dpa99c commented 6 years ago

The error message is arising from the plist module when attempting to rebuild the plist contents.

Please post the <config-file> block corresponding to the reported error key - without seeing it, it's not possible to diagnose the issue.

tobiasmuecksch commented 6 years ago

Ah, shoot. I forgot to add that. Thanks for the reminder.

The [...] means that I've removed code to make the xml code shorter. In case you need the full code let me know.

There you go:

    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
        <icon height="57" src="resources/ios/icon/icon.png" width="57" />
[...]
        <icon height="1024" src="resources/ios/icon/icon-1024.png" width="1024" />
        <splash height="1136" src="resources/ios/splash/Default-568h@2x~iphone.png" width="640"  />
[...]
        <splash height="2732" src="resources/ios/splash/Default@2x~universal~anyany.png" width="2732" />
        <config-file parent="NSContactsUsageDescription" target="*-Info.plist">
            <key>NSContactsUsageDescription</key>
            <string>displaying and syncing contacts</string>
        </config-file>
    </platform>
tobiasmuecksch commented 6 years ago

I've tried it without the parent attribute too, like this:

    <config-file parent="NSContactsUsageDescription" target="*-Info.plist">
            <key>NSContactsUsageDescription</key>
            <string>displaying and syncing contacts</string>
        </config-file>

But still the same error.

dpa99c commented 6 years ago

Specifying the <key> is causing the problem since it's already been defined by the parent attribute. The platform="ios" attribute is also necessary for <config-file> blocks.

<config-file platform="ios" parent="NSContactsUsageDescription" target="*-Info.plist">
    <string>displaying and syncing contacts</string>
</config-file>

You may to need to re-add the iOS platform to start with a fresh *-Info.plist:

cordova rm platform ios --nosave && cordova platform add ios --nosave
tobiasmuecksch commented 6 years ago

That did the trick. Thank you so much!