Cordova Info.plist NSCameraUsageDescription key is missing

Pavel Kovalev picture Pavel Kovalev · Sep 19, 2016 · Viewed 40k times · Source

After recent changes Apple requires specific keys if your app attempts to access privacy-sensitive data. So I added NSCameraUsageDescription key in my config.xml like this:

<platform name="ios">
    <config-file parent="NSCameraUsageDescription" target="*-Info.plist">
        <string>We are using a camera to </string>
    </config-file>
</platform>

Then

cordova build ios --release --device

produces the ipa which apparently doesn't have the right info in info.plist. It feels like I'm missing something.

Question 1: What do I need to put into config.xml to solve NSCameraUsageDescription issue? Question 2: Is it possible to use localization for this string?

Thank you!

Answer

jcesarmobile picture jcesarmobile · Sep 19, 2016

NEW ANSWER:

Since Cordova CLI 6.5.0 you can write in the info.plist directly by using the edit-config tag in the config.xml like this:

    <string>your usage message</string>
</edit-config>

But make sure you are using latest version of the plugins or values might be overwritten by the plugin variables.

For localizations you can use the resource-file tag and InfoPlist.strings files like in this plugin (but you don't need the plugin, resource-file tag is supported from the config.xml)

https://github.com/MBuchalik/cordova-plugin-ios-permissions


OLD ANSWER:

You can't write on the info.plist from the config.xml using the config-file tag yet (it's being worked on)

Latest version of the camera plugin allows you to add the NSCameraUsageDescription when you install the plugin

cordova plugin add cordova-plugin-camera --variable CAMERA_USAGE_DESCRIPTION="your usage message"

Right now it's not possible to localize this string