Adding property list keys for iOS development with Ionic

December 21, 2017, 9:00 am Categories:


Since iOS 10 applications require user permission to access hardware features such as the Camera or features such as the device media library.

This can be frustrating when testing applications developed with Ionic Native plugins only to be greeted with an Xcode error message like the following:

NSPhotoLibraryUsageDescription key must be present in Info.plist

Some developers using the Ionic Framework may have little experience working with Xcode but fixing this issue is actually quite simple.

Manage your property list

The solution to this particular issue?

Adding the necessary Cocoa keys to the application's Xcode property list.

This of course necessitates that you know what keys need to be added and how to correctly add those. Thankfully the Apple Developer documentation details all of the available Cocoa keys that can be defined within the application's property list.

Within Xcode open the Project navigator, expand the Resources directory and right-click on the Xcode property list (this ends with a .plist extension) that's contained within there.

From the contextual menu that is displayed select the Open As > Source Code option:

Selecting Source Code option in Xcode for adding Cocoa Keys to the project's property list

This will then allow you to directly edit this property list within Xcode and add the necessary Cocoa keys.

For example the following Cocoa keys are used to request user access to the device camera and photolibrary:

<string>This app requires access to the photo library.</string>
<string>This app requires access to the camera.</string>

These can simply be added to the top of the property list, above the existing keys, as highlighted in the following screen capture:

Cocoa keys added to an Xcode's project property list

Once added simply use Xcode to re-run the application on your handheld device and you should now find yourself being prompted for access to the device camera/photolibrary (or whatever other features you've added cocoa keys for) when requesting that functionality within the application.

In summary

Development related errors are never fun to deal with (particularly if you're under a tight deadline) but thankfully this is one simple issue to fix - and where development is concerned that can never be a bad thing!

If you've enjoyed what you've read and/or found this helpful please feel free to share your comments, thoughts and suggestions in the comments area below.

I explore further bug fixes and common error solutions for the Ionic framework within my e-book featured below and if you're interested in learning more about further articles and e-books please sign up to my FREE mailing list.



Post a comment

All comments are welcome and the rules are simple - be nice and do NOT engage in trolling, spamming, abusiveness or illegal behaviour. If you fail to observe these rules you will be permanently banned from being able to comment.