186

Using iOS 10.0 last beta. I had tried to use Camera to scan barcode in my app, and it crashed with this runtime error.

This app has crashed because it attempted 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.

Put this key into the plist, but it still crashed?

Cœur
  • 37,241
  • 25
  • 195
  • 267
user3069232
  • 8,587
  • 7
  • 46
  • 87
  • 6
    I have the same issue, added the NSCameraUsageDescription in info.plist, but still crashes with the same message. Have you managed to solve it? Apparently, nobody who answered this problem understood that it crashes even if you already added the key. – CarmenA Oct 03 '16 at 14:26
  • 1
    If you added the entry to the correct info.plist file, but it still failed, it may be because Xcode sometimes fails to notice changes to resource files like info.plist, images, audio, movies, etc. You may need to perform a clean or delete the app build product from the Derived Data folder to force Xcode to use the latest version. – Walt Sellers Oct 07 '18 at 22:45

14 Answers14

266

After iOS 10 you have to define and provide a usage description of all the system’s privacy-sensitive data accessed by your app in Info.plist as below:

Calendar

Key    :  Privacy - Calendars Usage Description    
Value  :  $(PRODUCT_NAME) calendar events

Reminder :

Key    :   Privacy - Reminders Usage Description    
Value  :   $(PRODUCT_NAME) reminder use

Contact :

Key    :   Privacy - Contacts Usage Description     
Value  :  $(PRODUCT_NAME) contact use

Photo :

Key    :  Privacy - Photo Library Usage Description    
Value  :  $(PRODUCT_NAME) photo use

Bluetooth Sharing :

Key    :  Privacy - Bluetooth Peripheral Usage Description     
Value  :  $(PRODUCT_NAME) Bluetooth Peripheral use

Microphone (also used for video recording) :

Key    :  Privacy - Microphone Usage Description    
Value  :  $(PRODUCT_NAME) microphone use

Camera (photo or video recording) :

Key    :  Privacy - Camera Usage Description   
Value  :  $(PRODUCT_NAME) camera use

Location :

Key    :  Privacy - Location Always Usage Description   
Value  :  $(PRODUCT_NAME) location use

Key    :  Privacy - Location When In Use Usage Description   
Value  :  $(PRODUCT_NAME) location use

Heath :

Key    :  Privacy - Health Share Usage Description   
Value  :  $(PRODUCT_NAME) heath share use

Key    :  Privacy - Health Update Usage Description   
Value  :  $(PRODUCT_NAME) heath update use

HomeKit :

Key    :  Privacy - HomeKit Usage Description   
Value  :  $(PRODUCT_NAME) home kit use

Media Library :

Key    :  Privacy - Media Library Usage Description   
Value  :  $(PRODUCT_NAME) media library use

Motion :

Key    :  Privacy - Motion Usage Description   
Value  :  $(PRODUCT_NAME) motion use

Speech Recognition :

Key    :  Privacy - Speech Recognition Usage Description   
Value  :  $(PRODUCT_NAME) speech use

SiriKit :

Key    :  Privacy - Siri Usage Description  
Value  :  $(PRODUCT_NAME) siri use

TV Provider :

Key    :  Privacy - TV Provider Usage Description   
Value  :  $(PRODUCT_NAME) tvProvider use

You can get detailed information in this link.

igorsantos07
  • 4,456
  • 5
  • 43
  • 62
Bhoopi
  • 6,523
  • 3
  • 22
  • 16
  • 1
    `Privacy - Photo Library Usage Description` did it for the error `NSPhotoLibraryUsageDescription` – Bruno Bieri May 17 '17 at 13:45
  • Im new to Apple Development and this issue was annoying. Glad I came upon it. Cheers! – user2529011 Aug 17 '18 at 20:26
  • 1
    @MaylorTaylor: Yes, you have to add it. – Bhoopi Aug 09 '19 at 06:05
  • I've lightly edited the answer to clarify that the Microphone permission is required (together with the Camera permission) for video recording. It's not really obvious and I thought a plain comment could not suffice for quick readers. – igorsantos07 Aug 24 '22 at 22:39
127

As Apple has changed how you can access any user private data types in iOS 10.

You need to add the "Privacy - Camera usage description" key to your app’s Info.plist and their usage information which is apply for your application, as in below example I had provided that I have used to scan barcodes.

For more information please find the below screenshot.

enter image description here

Community
  • 1
  • 1
Ramkrishna Sharma
  • 6,961
  • 3
  • 42
  • 51
67

You have to add this below key in info.plist.

NSCameraUsageDescription Or Privacy - Camera usage description

And add description of usage.

Detailed screenshots are available in this link

Zaheer Abbas
  • 225
  • 1
  • 2
  • 10
Bluewings
  • 3,438
  • 3
  • 18
  • 31
  • It sounds like he already added that but still getting the crash. It's the same issue I'm having where even though that KVP is in the plist, it's still crashing as if it isn't. –  Sep 30 '16 at 18:15
62

Alternatively open Info.plist as source code and add this:

<key>NSCameraUsageDescription</key>
<string>Camera usage description</string>
ayalcinkaya
  • 3,303
  • 29
  • 25
  • 4
    in case someone is looking to localise the "NSCameraUsageDescription", add `"NSCameraUsageDescription" = "Requires access to the camera";` in your localised **infoPlist.strings** file – Khurram Shehzad Nov 16 '16 at 04:35
48

Use these raw values and copy in info.plist

    <key>NSCalendarsUsageDescription</key>
      <string>$(PRODUCT_NAME) calendar events</string>
    <key>NSRemindersUsageDescription</key>
      <string>$(PRODUCT_NAME) reminder use</string>
    <key>NSCameraUsageDescription</key>
      <string>This app requires to access your photo library to show image on profile and send via chat</string>
    <key>NSMicrophoneUsageDescription</key>
      <string>This app requires to access your microphone to record video with your voice send via chat</string>
    <key>NSPhotoLibraryUsageDescription</key>
      <string>This app requires to access your photo library to show image on profile and send via chat</string>
    <key>NSContactsUsageDescription</key>
       <string>$(PRODUCT_NAME) contact use</string>
    <key>NSLocationAlwaysUsageDescription</key>
      <string>$(PRODUCT_NAME) location use</string>
    <key>NSLocationWhenInUseUsageDescription</key>
      <string>$(PRODUCT_NAME) location use</string>
Zeeshan
  • 4,194
  • 28
  • 32
29

the xcode UI has changed a bit from one version to the next so here is where you update the plist for 9.0 beta 4 if it helps Project ->Target ->Infoenter image description here

user3325025
  • 654
  • 7
  • 10
  • 2
    This should be the accepted answer! I was having this very same issue on XCode 9.2, despite already having added `NSCameraUsageDescription` to the *info.plist*. – psantos Dec 15 '17 at 15:20
  • 2
    Definitely accepted answer!! I have two targets in my project, and I've tried to add this `NSCameraUsageDescription` to the second _info.plist_ file, but with no effect, and I can confirm that XCode (10.1) is definitely not taking those changes into account by running git status, because my _info.plist_ for another target didn't have any changes. So the right way is to go through the _Project->Target->Info_. Thanks man! – bra.Scene Apr 22 '19 at 10:04
8

If you're using Ionic, you can solve it directly from config.xml by adding inside platform ios tag:

<platform name="ios">
.
.
.
    <config-file target="*-Info.plist" parent="NSPhotoLibraryUsageDescription">
        <string>photo library usage description</string>
    </config-file>
    <config-file target="*-Info.plist" parent="NSCameraUsageDescription">
        <string>camera usage description</string>
    </config-file>
.
.
.
</platform>

I'd like to thank @BHUPI answer too.

6

For those who are still getting the error even though you added proper keys into Info.plist:

Make sure you are adding the key into correct Info.plist. Newer version of xCode, apparently has 3 Info.plist.

One is under folder with your app's name which solved problem for me.

Second is under YourappnameTests and third one is under YourappnameUITests.

Hope it helps.

Vetuka
  • 1,523
  • 1
  • 24
  • 40
4

Another instance that I faced while trying to use the camera, was that it was still busy crashing giving same _CRASHING_DUE_TO_PRIVACY even after adding the "Camera Usage Description". After failing to get anything tangible from the call stack, switched to the "Organizer" and looked into the crash reports on the device. I found that it was in fact complaining about the privacy due to the missing "Microphone Usage Description". I added that and got rid of such a cryptic break down.

Devid Farinelli
  • 7,514
  • 9
  • 42
  • 73
Yoku
  • 307
  • 5
  • 16
2

You do this by adding a usage key to your app’s Info.plist together with a purpose string. NSCameraUsageDescription Specifies the reason for your app to access the device’s camera

https://developer.apple.com/library/content/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html

2

I checked the plist and found it is not working, only in the "project" info, you need to add the "Privacy - Camera ....", then it should work. Hope to help you.

Mark
  • 107
  • 1
  • 1
2

I had the same problem and could not find a solution. Mark90 is right there are a lot info.plist files and you should edit the correct. Go to Project, under TARGETS select the project (not the tests), in the tab bar select Info and add the permission under "Custom iOS Target Properties".

0

For those that like myself are testing an Ionic project and have to add privacy permission keys, make sure you add them in the right .plist file. The best way to find it is to use Xcode search, the one with your app name is the one. I share a screenshot with a circle around the right Info.plist you need to modify. I had lost time modifying the other one in the library folder and resulted in errors about privacy. Hope this screenshot helps. In my case at the bottom of the file I clicked on + and scrolled until I found Privacy - Camera usage description, I inserted the short description used for Qrcodes and worked

enter image description here

Pietro
  • 127
  • 6
0

My problem was solved by the fact that I added a field in the application target, since this field did not exist.

Screenshot 1 Screenshot 2

Jeremy Caney
  • 7,102
  • 69
  • 48
  • 77