Thursday, November 10, 2016

Info.plist must contain an NSPhotoLibraryUsageDescription key Objective C

If you are using UIImagePickerController in your project and recently
you have been updated to XCode 8 then will get the mentioned error. Your app will crash. Don't worry, you just need to add a key in the info.plist. You can add this key in two ways in this plist.

Method 1:
Right click on the plist then select show in finder. In the finder open this info.plist with "TextEdit" or any other text editing app. Then find </dict> and paste the code snippet below just above it (See Image 1).

Save it and then open this new plist in the XCode. You will notice a new row there like Image 2.

NSPhotoLibraryUsageDescription
Photo Library Access Warning


Image 2: info.plist in XCode after adding
the Photo Library using TextEdit

Image 1: Adding Key pair for Photo Library
in Info.plist using TextEdit














Method 2:
Method 1 can be a little bit risky. Because if you accidentally break the pair of key and type in the XML file it will cause an error in XCode. That's why I prefer this method 2. In this method open this plist in the XCode. Click on + sign beside of Information Property List. In the new row, type "Privacy - Photo Library Usage Description" (Image 3).  Close it. Now you are ready to run your project.

Image 3:Adding Photo Library from XCode



No comments:

Post a Comment