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


#1

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

#2

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>

#3

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

#4

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


#5

The only thing really works. Thanks!