iospermissionsios11

What is the crash of "The app's Info.plist must contain an NSPhotoLibraryAddUsageDescription"?


I faced the following error (iOS 11):

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.

Note that although the application info.plist does contains NSPhotoLibraryUsageDescription it still crashes, why?


Solution

  • Note that although the application info.plist does contains NSPhotoLibraryUsageDescription it still crashes, why?

    I think there is a misunderstanding when comparing NSPhotoLibraryUsageDescription and NSPhotoLibraryAddUsageDescription, as documented in Information Property List Key Reference:

    NSPhotoLibraryUsageDescription:

    This key lets you describe the reason your app accesses the user’s photo library. When the system prompts the user to allow access, this string is displayed as part of the alert.

    It is related to letting the app to be able to access (get) the device photos library.

    NSPhotoLibraryAddUsageDescription:

    This key lets you describe the reason your app seeks write-only access to the user’s photo library. When the system prompts the user to allow access, this string is displayed as part of the alert.

    It is related to letting the app to be able to write (add) photos into the device photos library.


    Obviously, to solve this crash you have to add the NSPhotoLibraryAddUsageDescription into the application's plist file:

    <key>NSPhotoLibraryAddUsageDescription</key>
    <string>Our application needs permission to write photos...</string>
    

    As property list view:

    enter image description here