Cordova Info.plist NSCameraUsageDescription key is missing

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


Here are results of my own research:

    • Yes, you can modify info.plist from the config.xml file using the config-file tag, but you have to use a plugin for that (cordova custom config) and follow the instructions religiously.
    • However, probably a better option is to use plugin.xml to do the same thing. More about it you can read here (modifying info plist from plugin.xml)
    • Another option as @jcesarmobile mentioned - current camera plugin may support it like cordova plugin camera (this solution is specific to the plugin)
    • Yes, it is possible to localize a string inside the info.plist file but it requires to use xcode for that. I'm not sure how to localize a string inside the info.plist file using Cordova config.xml or plugin.xml

Please, correct me if I wrong. More info on the localization directly from config.xml is appreciated.

Personally, I don't like the idea to use a custom plugin to modify an info.plist file. It feels like with every new plugin I use make my app more and more fragile. :)


First, this works for me with Cli-7.1.0 after apple rejects my ipa.

1) In your code, if you use for ex. cordova-plugin-barcodescanner and cordova-plugin-camera and cordova-plugin-ios-camera-permissions all the variables CAMERA_USAGE_DESCRIPTION, PHOTOLIBRARY_USAGE_DESCRIPTION should have the same string inside. If one of them is different apple rejects your ipa, because phonegap use the default variable .

ej:

<plugin name="cordova-plugin-ios-camera-permissions" >
     <variable name="CAMERA_USAGE_DESCRIPTION" value="YOUR-PERMISSION-REQUEST" />
     <variable name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="YOUR-PERMISSION-REQUEST" />
</plugin><!-- spec="1.0.3" !-->

<plugin name="cordova-plugin-camera" > 
     <variable name="CAMERA_USAGE_DESCRIPTION" value="YOUR-PERMISSION-REQUEST" />
     <variable name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="YOUR-PERMISSION-REQUEST" />

<gap:plugin name="cordova-plugin-image-picker" source="npm" />
<gap:plugin name="cordova-plugin-base64-joewsh" source="npm" />   <!-- convertir a base64 los files !-->


<gap:plugin name="cordova-plugin-barcodescanner"   source="npm" spec="0.7.0" >

     <variable name="CAMERA_USAGE_DESCRIPTION" value="YOUR-PERMISSION-REQUEST" />
</gap:plugin>

2) add this code (remember to use the same string in the variables, as I mention before):

<platform name="ios">

     <edit-config target="NSLocationWhenInUseUsageDescription" file="*-Info.plist" mode="merge" overwrite="true">
          <string>YOUR-PERMISSION-REQUEST</string>
     </edit-config>
     <edit-config target="NSPhotoLibraryUsageDescription" file="*-Info.plist" mode="merge" overwrite="true" >
          <string>YOUR-PERMISSION-REQUEST</string>
     </edit-config>
     <edit-config target="NSCameraUsageDescription" file="*-Info.plist" mode="merge" overwrite="true">
          <string>YOUR-PERMISSION-REQUEST</string>
     </edit-config>
</platform>

You can manually edit the .plist file within your cordova project if you wish. This worked for me but since this is a generated file I do worry at some point my changes might get over written.

But onto helping!

The .plist file should be located within your Cordova project within the /platforms/ios/[Cordova Project Name]/[Cordova Project Name]-Info.plist. You can also open up the project in Xcode and along the left hand side click the Magnifier icon which will let you search for files in the project. If you enter in info.plist it should return a result that shows something like:

INFOPLIST_FILE = [Some]/[Path]/[Cordova Project Name]-Info.plist

This path should be relative to your Cordova project install so searching within your project should lead you to the correct file.

I opened up this file in my editor and added the following lines just inside the first opening <dict> tag:

<key>NSCameraUsageDescription</key> <string>Uses camera to allow video chatting between two clients</string>

I was able to submit and have my build show up and stay in itunesconnect. Currently still waiting app review.

I did run a cordova prepare ios just to test if my changes would get over written which they did not so it looks like you should be able to do this and not worry about it but be weary of other devs installing your application and running into the same issue. I just copied my updated .plist file into the root of my repo and made note of it in the readme.