8

When I try and load upload my iTunes app installer to iTunes I relieve this error:

Missing Info.plist key - This app attempts to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSPhotoLibraryUsageDescription key with a string value explaining to the user how the app uses this data.

Missing Info.plist key - This app attempts to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data.

What can I add to my config file below to let this work:

<preference name="permissions" value="none" />
    <preference name="orientation" value="default" />
    <preference name="target-device" value="universal" />
    <preference name="fullscreen" value="false" />
    <preference name="webviewbounce" value="false" />
    <preference name="disallowOverscroll" value="true" />
    <preference name="prerendered-icon" value="true" />
    <preference name="stay-in-webview" value="false" />
    <preference name="ios-statusbarstyle" value="black-opaque" />
    <preference name="detect-data-types" value="true" />
    <preference name="exit-on-suspend" value="false" />
    <preference name="show-splash-screen-spinner" value="true" />
    <preference name="auto-hide-splash-screen" value="true" />
    <preference name="disable-cursor" value="false" />
    <preference name="android-minSdkVersion" value="10" />
    <preference name="android-targetSdkVersion" value="19" />
    <preference name="android-installLocation" value="auto" />
    <gap:plugin name="org.apache.cordova.battery-status" source="npm" />
    <gap:plugin name="org.apache.cordova.camera" source="npm"/>    
    <gap:plugin name="org.apache.cordova.media-capture" source="npm"/>
    <gap:plugin name="org.apache.cordova.console" source="npm" />
    <gap:plugin name="org.apache.cordova.contacts" source="npm"/>

    <gap:plugin name="org.apache.cordova.device-motion" source="npm"/>
    <gap:plugin name="org.apache.cordova.device-orientation" source="npm"/>
    <gap:plugin name="org.apache.cordova.dialogs" source="npm"/>
    <gap:plugin name="org.apache.cordova.file" source="npm"/>
    <gap:plugin name="org.apache.cordova.file-transfer" source="npm"/>

    <gap:plugin name="org.apache.cordova.inappbrowser" source="npm"/>
    <gap:plugin name="org.apache.cordova.media" source="npm"/>
    <gap:plugin name="org.apache.cordova.network-information" source="npm"/>
    <gap:plugin name="org.apache.cordova.splashscreen" source="npm"/>
    <gap:plugin name="org.apache.cordova.vibration" source="npm"/>
    <icon src="icon.png" />

    <gap:splash src="splash.png" gap:platform="android" gap:qualifier="port-ldpi" />
    <gap:splash src="splash.png" gap:platform="android" gap:qualifier="port-mdpi" />
    <gap:splash src="splash.png" gap:platform="android" gap:qualifier="port-hdpi" />
    <gap:splash src="splash.png" gap:platform="android" gap:qualifier="port-xhdpi" />
    <gap:splash src="splash.png" gap:platform="blackberry" />
    <gap:splash src="splash.png" gap:platform="ios" width="320" height="480" />
    <gap:splash src="splash.png" gap:platform="ios" width="640" height="960" />
    <gap:splash src="splash.png" gap:platform="ios" width="640" height="1136" />
    <gap:splash src="splash.png" gap:platform="ios" width="768" height="1024" />
    <gap:splash src="splash.png" gap:platform="ios" width="1024" height="768" />
    <gap:splash src="splash.png" gap:platform="winphone" />
    <access origin="*" />

    <gap:plugin name=" phonegap-plugin-barcodescanner" source="npm" />
    <gap:plugin name="uk.co.workingedge.phonegap.plugin.launchnavigator" source="npm" />
    <gap:plugin name="cordova-plugin-directions" source="npm" />


    <!-- iPhone / iPod Touch  - lower 4s -->
    <icon src="icon-57.png" gap:platform="ios" width="57" height="57" />
    <icon src="icon.png" gap:platform="ios" width="114" height="114" />
    <icon src="icon-72.png" gap:platform="ios" width="72" height="72" />
    <icon src="152.png" gap:platform="ios" width="152" height="152" />
    <icon src="icon-120.png" gap:platform="ios" width="120" height="120" />
    <icon src="76.png" gap:platform="ios" width="76" height="76" />
    <icon src="icon-40.png" gap:platform="ios" width="40" height="40" />

    <!-- iPhone / iPod Touch - 5-5s -->
    <icon src="icon.png" gap:platform="ios" width="60" height="60" />
    <icon src="icon.png" gap:platform="ios" width="120" height="120" />
    <!-- iPhone6-6+ -->
    <icon src="icon.png" gap:platform="ios" width="180" height="180" />

    <!-- Settings Icon -->
    <icon src="icon-29.png" gap:platform="ios" width="29" height="29" />
    <icon src="icon.png" gap:platform="ios" width="58" height="58" />

    <!-- Spotlight Icon -->
    <icon src="icon.png" gap:platform="ios" width="40" height="40" />
    <icon src="icon.png" gap:platform="ios" width="80" height="80" />

    <plugin name="cordova-plugin-whitelist" version="1" source="npm"/>

    <gap:plugin name="cordova-plugin-geolocation" source="npm"/>

    <feature name="http://api.phonegap.com/1.0/battery" />
    <feature name="http://api.phonegap.com/1.0/camera" />
    <feature name="http://api.phonegap.com/1.0/network" />
    <feature name="http://api.phonegap.com/1.0/notification" />

    <gap:plugin name="cordova-plugin-x-socialsharing" source="npm" />
Mike
  • 6,751
  • 23
  • 75
  • 132
  • I tried this fix but it didnt work: https://medium.com/collaborne-engineering/cordova-ios-10-nscamerausagedescription-missing-fbcbe5e41565#.duxoaay7a – Mike Jan 07 '17 at 22:06
  • you might be need to follow http://stackoverflow.com/questions/38498275/ios-10-changes-in-asking-permissions-of-camera-microphone-and-photo-library-c – Naitik Jan 09 '17 at 10:11

6 Answers6

21

Another edit: Most plugins removed the variables for usage description, so now the way of setting them is using edit-config tag in the config.xml like this.

<edit-config target="NSCameraUsageDescription" file="*-Info.plist" mode="overwrite">
    <string>We are using the Camera for something...</string>
</edit-config>

But not all plugins have been updated yet, so better read the plugin's README.md before. On the core plugins it's in a section called iOS Quirks.

It also needs the cli 7.0.1 or newer, set it in the config.xml like this:

<preference name="phonegap-version" value="cli-8.0.0" />

EDIT:

My old answer no longer works if you have <preference name='phonegap-version' value='cli-7.0.1' /> (or if you don't have any phonegap-version as it will use it as default)

To set the usage descriptions use the params on the plugin

<plugin name="cordova-plugin-camera">
   <param name="CAMERA_USAGE_DESCRIPTION" value="We are using the Camera for something..." />
   <param name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="We are using the Photo Library for something..." />
</plugin>

Beware that if you have some plugins with the same usage descriptions and you don't fill them with param tags they might be replaced with the default empty string

You can force to use the old builder with this tag, but it's not recommended, the new builder is better <preference name='pgb-builder-version' value='1' />

OLD ANSWER:

You can write in the info.plist like this:

<gap:config-file platform="ios" parent="NSCameraUsageDescription" overwrite="true">
   <string>We are using the Camera for something...</string>
</gap:config-file>

The overwrite="true" is important because latest version of the camera plugin is already writing empty values.

I have tested it on a sample app and it's working https://github.com/jcesarmobile/phonegap-template-hello-world/blob/454e852955e66470890cba636450abd422f50598/config.xml#L153-L155

jcesarmobile
  • 51,328
  • 11
  • 132
  • 176
  • Awesome, was able to figure it out with your suggestion. Just had to take this line out: from the top – Mike Jan 20 '17 at 23:28
  • I edited it an took it out. Also for in my code I just copied the same code and added a second one for NSCameraUsageDescription – Mike Jan 20 '17 at 23:29
  • 1
    yeah, sorry, I copied part of the NSPhotoLibraryUsageDescription section that was above. I have updated the link to the config.xml of my sample app pointing to just the right lines for the NSCameraUsageDescription – jcesarmobile Jan 20 '17 at 23:54
  • I have added it like this but i am getting the same error. – Mohan Feb 19 '18 at 06:59
  • @jcesarmobile Thanks for the update.. Its working fine now. – Mohan Feb 19 '18 at 12:40
2

Please open your project in xcode and go to your .plist file in resources folder,

Then at end of in you .plist file click on "+" and add search for "Privacy - Photo Library Usage Description" and add it's value in beside column.

same please do for "NSCameraUsageDescription" again click on "+" and search for "Privacy - Camera Usage Description" and again give some usage description in beside column.

it will solve you issue.

For more info please visit following:

1) Stackoverflow question related to your question 2) Official apple doc for all required keys to be added

Community
  • 1
  • 1
Naitik
  • 1,455
  • 15
  • 26
  • I am using phonegap and phonegap build. I do not have a plist file. I need to add soemthing to my config.xml – Mike Jan 10 '17 at 02:58
  • so you need to follow http://stackoverflow.com/questions/22769111/add-entry-to-ios-plist-file-via-cordova-config-xml and add above permission – Naitik Jan 10 '17 at 10:32
1

Before you access privacy-sensitive data like Camera, Contacts, and so on, you must ask for the authorization, your app will crash when you access them.Then Xcode will log like:

This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSContactsUsageDescription key with a string value explaining to the user how the app uses this data.

How to deal with this? As apple say:

You must statically declare your app’s intended use of protected data classes by including the appropriate purpose string keys in your Info.plist file.

In your case you may have to add the following in your info.plist,

<!-- Photo Library --> <key>NSPhotoLibraryUsageDescription</key> <string>$(PRODUCT_NAME) photo use</string>

Also suggest you to look at this link for more detailed info on this. Hope it helps.

You can also check out this plugin which helps in manipulating *-info.plist

Gandhi
  • 11,875
  • 4
  • 39
  • 63
  • How do I add this with PhoneGap builder? there is no info.plist just a config file? – Mike Jan 20 '17 at 03:46
  • @Mike info.plist file will be avalilable under platforms/ios/ROJECT_NAME folder. you can make use of config-file configurations to alter info.plist. Check out this link - http://cordova.apache.org/docs/en/6.x/plugin_ref/spec.html#config-file Hope it helps – Gandhi Jan 20 '17 at 05:41
  • @Gandhi he is using Phonegap Build, there is no platforms folder there or any way of manually editing the info.plist, the way of doing it is as I told, not sure why he didn't try my answer :( – jcesarmobile Jan 20 '17 at 09:55
  • @jcesarmobile Hi, thanks for the clarification. I m not sure about the phonegap architecure as i dont have handson exeperience on it. I was trying to answer it from cordova perspective. But what you have suggested and what i have mentioned in the comment of my answer looks the same. i.e using config-file Guess we can upvote each others answer :) i m upvoting yours. – Gandhi Jan 20 '17 at 10:26
  • It's not really the same, the config-file you mention only works on plugins at the moment on Cordova, and camera, media-capture and all the other plugins requiring usage descriptions already have those entries. The one I mention is specific to Phonegap Build. I usually upvote your answers, but only when you are 100% right. BTW, you are doing a great work on cordova tag – jcesarmobile Jan 20 '17 at 11:00
  • @jcesarmobile But the docs say that it supports manipulating info.plist file in iOS. Not tried though. Anyways thanks for your acknowledgement – Gandhi Jan 20 '17 at 11:23
  • @jcesarmobile didnt see your answer earlier about to give it a try, thanks! – Mike Jan 20 '17 at 22:10
1

In ios you need to install camera-plugin with barcodescanner-plugin after you have to put below line in config.xml for overwriting plist file.

<gap:plugin name="phonegap-plugin-barcodescanner" source="npm" />

<preference name="android-build-tool" value="gradle" />

<config-file platform="ios" target="*-Info.plist" parent="NSCameraUsageDescription">
    <string>It is used for scaning QR code.</string>
</config-file>

<edit-config platform="ios" target="*-Info.plist" parent="NSCameraUsageDescription" mode="merge">
    <string>It is used for scaning QR code.</string>
</edit-config>

<config-file platform="ios" target="*-Info.plist" parent="NSPhotoLibraryUsageDescription">
    <string>It is used for scanning QR code</string>
</config-file>

<edit-config platform="ios" target="*-Info.plist" parent="NSPhotoLibraryUsageDescription" mode="merge">
    <string>It is used for scanning QR code</string>
</edit-config>
Himanshu
  • 251
  • 4
  • 18
0

None of the answers here worked for me exactly so I figure I should add my two cents as to how I got this working.

First, I tried the accepted answer (the one written by jcesarmobile). When i tried this and ran: phonegap build ios everytime the configuration was deleted from my config.xml file. So next I tried the solution indicated here:

http://geeklearning.io/how-to-add-specific-configuration-parameters-to-ios-p-list-and-android-manifest/

This did not work at first, There were a number of changes that had to be made, all of which I got from the github repo comments on the file. I suggest you run the build, copy the error message and search in the comments and do what they say. Once I got it to build again, It still did not work upon uploading the itunes connect.

In the end I had to open up the Info.plist file and manually put in the following

<key>NSCameraUsageDescription</key>
<string>We are using the Camera to (blah blah blah, your explanation)</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>We are using the Photo Library to (your reason)</string>
<key>NSMainNibFile</key>

Even though the hook did not do exactly as it claimed I still think it was important because before I did this everything was getting deleted, and now it stays put.

I hope this helps someone out.

Dallas Caley
  • 5,367
  • 6
  • 40
  • 69
0

Phonegap Build - for anyone using cli-7.0.1 as probably everyone should be now:

<edit-config target="NSPhotoLibraryUsageDescription" file="*-Info.plist" mode="overwrite">
    <string>Used to allow the user to select media to upload to us</string>
</edit-config>

That does NOT go within the tag, simply within the Widget tag like everything else. Change the string to whatever it suitable for you.

klidifia
  • 1,415
  • 1
  • 12
  • 18