NSPhotoLibraryAddUsageDescription error
Asked Answered
M

3

5

I hope someone can help here. I have this Xcode / Unity project, and every time I try to build it I get this 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 NSPhotoLibraryAddUsageDescription key with a string value explaining to the user how the app uses this data.

I understand that in my info.plist I need a description for use of camera, library etc, but as far as I can see, I have that?

Here is my info.plist:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
  <dict>
    <key>CFBundleDevelopmentRegion</key>
    <string>en</string>
    <key>CFBundleDisplayName</key>
    <string>MyGame</string>
    <key>CFBundleExecutable</key>
    <string>${EXECUTABLE_NAME}</string>
    <key>CFBundleIconFiles</key>
    <array>
      <string>AppIcon57x57.png</string>
      <string>[email protected]</string>
      <string>[email protected]</string>
      <string>AppIcon72x72@2x~ipad.png</string>
      <string>AppIcon72x72~ipad.png</string>
      <string>AppIcon76x76@2x~ipad.png</string>
      <string>AppIcon76x76~ipad.png</string>
    </array>
    <key>CFBundleIdentifier</key>
    <string>com.mycompany.${PRODUCT_NAME}</string>
    <key>CFBundleInfoDictionaryVersion</key>
    <string>6.0</string>
    <key>CFBundleName</key>
    <string>${PRODUCT_NAME}</string>
    <key>CFBundlePackageType</key>
    <string>APPL</string>
    <key>CFBundleShortVersionString</key>
    <string>1.0.3</string>
    <key>CFBundleVersion</key>
    <string>1</string>
    <key>LSRequiresIPhoneOS</key>
    <true />
    <key>NSAppTransportSecurity</key>
    <dict>
      <key>NSAllowsArbitraryLoads</key>
      <true />
    </dict>
    <key>UIApplicationExitsOnSuspend</key>
    <false />
    <key>UILaunchStoryboardName~ipad</key>
    <string>LaunchScreen-iPad</string>
    <key>UILaunchStoryboardName~iphone</key>
    <string>LaunchScreen-iPhone</string>
    <key>UILaunchStoryboardName~ipod</key>
    <string>LaunchScreen-iPhone</string>
    <key>UIPrerenderedIcon</key>
    <false />
    <key>UIRequiredDeviceCapabilities</key>
    <array>
      <string>armv7</string>
    </array>
    <key>UIRequiresFullScreen</key>
    <true />
    <key>UIRequiresPersistentWiFi</key>
    <false />
    <key>UIStatusBarHidden</key>
    <true />
    <key>UIStatusBarStyle</key>
    <string>UIStatusBarStyleDefault</string>
    <key>UISupportedInterfaceOrientations</key>
    <array>
      <string>UIInterfaceOrientationPortrait</string>
    </array>
    <key>Unity_LoadingActivityIndicatorStyle</key>
    <integer>-1</integer>
    <key>UnityCloudProjectID</key>
    <string>xxx-xxx-xxx-xxx-xxx</string>
    <key>UnityCrashSubmissionURL</key>
    <string>https://a:[email protected]/symbolicate</string>
    <key>NSCameraUsageDescription</key>
    <string>Used for profile image</string>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>Used for profile image</string>
    <key>FacebookAppID</key>
    <string>xxxxx</string>
    <key>CFBundleURLTypes</key>
    <array>
      <dict>
        <key>CFBundleURLName</key>
        <string>facebook-unity-sdk</string>
        <key>CFBundleURLSchemes</key>
        <array>
          <string>xxxxx</string>
        </array>
      </dict>
    </array>
    <key>LSApplicationQueriesSchemes</key>
    <array>
      <string>fbapi</string>
      <string>fb-messenger-api</string>
      <string>fbauth2</string>
      <string>fbshareextension</string>
    </array>
  </dict>
</plist>

As you can see, i do have the descriptions in there?!?!

When viewing the info.plist inside Xcode it looks like this

enter image description here

really hope that someone can help me in this matter, and thanks in advance :-)

Magbie answered 6/10, 2017 at 8:49 Comment(3)
Error says that your plist needs to have NSPhotoLibraryAddUsageDescription entry and your plist doesn't have it. What exactly is unclear about this error?Usn
Possible duplicate of Photo capture permission problems in iOS 11Pearl
@VarunNaharia Is right, can close this question?Carbajal
R
8

You need to add below code in info.plist

<key>NSPhotoLibraryAddUsageDescription</key>
<string>Here write description why you accessing photo library</string>

Privacy - Photo Library Usage Description is for read and write libraries, NSPhotoLibraryAddUsageDescription is only for read. If your app needs only read add NSPhotoLibraryAddUsageDescription

For more details see this link, https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CocoaKeys.html#//apple_ref/doc/uid/TP40009251-SW73

See the below screenshots:

1) Right click on Info.plist file

--> Select Open As option

--> Click Source Code

enter image description here

2) Now copy and paste above code here.

enter image description here

Rockel answered 3/11, 2017 at 7:2 Comment(0)
W
4

You need to add NSPhotoLibraryAddUsageDescription in info.plist file in iOS 11.

If you want to add photo/image in your photo library then you must add this key to info.plist file

Wavawave answered 6/10, 2017 at 8:50 Comment(1)
The documentation says: "NSPhotoLibraryUsageDescription (String - iOS) This key lets you describe the reason your app accesses the user’s photo library. Although this keys governs read and write access to the user’s photo library, it’s best to use NSPhotoLibraryAddUsageDescription if your app needs only to add assets to the library and does not need to read any assets." Any thoughts on why the AddUsage key, defined as write only, would be needed when the Usage key (per documentation) governs read and write access?Spic
R
3

I have found that you also need to add

<key>NSCameraUsageDescription</key>
<string>Photo Library Access Warning</string>

or it will still crash. You need all three at the moment - March 2018

Rich answered 8/3, 2018 at 1:8 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.