How to add keys to `xxx-info.plist` for `ionic platform add ios`

I have a cordova plugin cordova-plugin-camera-roll-location I am updating to swift3

As part of the process, I get this error with the latest version of xcode:

[access] This app has crashed because it attempted to access privacy-sensitive data without a usage description.  
The app's Info.plist must contain an NSPhotoLibraryUsageDescription key 
with a string value explaining to the user how the app uses this data.

The solution was found here: http://stackoverflow.com/questions/39519773/nsphotolibraryusagedescription-key-must-be-present-in-info-plist-to-use-camera-r

        // ./platforms/ios/myapp/myapp-info.plist
	<key>NSPhotoLibraryUsageDescription</key>
	<string>Photo Library Access Warning</string>

I need to add some keys to my app plist. I can do that manually in xcode and everything works fine. But how do I do this generically so that the keys appear when the user runs:

ionic platform add ios 
ionic build ios
1 Like

This post revealed the answer: http://stackoverflow.com/questions/22769111/add-entry-to-ios-plist-file-via-cordova-config-xml

to add these lines to your -info.plist

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

add these lines to plugin.xml

     <!-- ios -->
    <platform name="ios">
      <config-file target="*-Info.plist" parent="NSPhotoLibraryUsageDescription">
        <string>Photo Library Access Warning</string>
      </config-file>
    </platform>
1 Like

I had to add the lines to config.xml not platform.xml. Hope this helps someone who might otherwise look for plugin.xml

config.xml

<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>
...
7 Likes

Thanks for this, all other ‘solutions’ I’ve found haven’t worked!

The only thing really works. Thanks!

This worked with all the latest tech at the moment.

This solution worked for me perfectly.
Thanks

you need to open info.plist in xcode and add description for require plugin like location.
1-go to projectFolder/platforms/ios/yourAppName/yourAppName-Info.plist
2-open yourAppName-Info.plist in xcode
3-find your plugin with and in value field describe to user why you need to access this plugin.

for example in photo we need access bluetooth and in value field we wrote “This app requires constant Bluetooth access to function properly.” but you need to explain more.

for more information and learn more you can open below link thanks…

1 Like