Plugin.xml contains variables/preferences but after build the info.plist not

Hey guys,

in this example I’m using Ionic v2 and the cordova-plugin-camera plugin.
We have this iOS informations in the plugins plugin.xml.

And if I compile it without having the platform “iOS” added yet, I get a newly created Info.plist with this settings.

You can see, that the Privacy - Photo Library Usage Description (3. from bottom) is not set / empty. You can see that the camera usage description (7. from top) is not set / empty.

My plugin.xml looks like…

<?xml version='1.0' encoding='utf-8'?>
<widget id="org.example" version="1.2.3.4.5" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <plugin name="cordova-plugin-camera" spec="~2.3.0">
        <variable name="CAMERA_USAGE_DESCRIPTION" value="Profile picture / Profilbild" />
        <variable name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="Profile picture / Profilbild" />
    </plugin>
</widget>

Now the question is why?
Is it my fault? Is it a bug from Ionic? Is it a bug from the plugin? Is it a bug from cordova?

Thank you in Advance for any ideas :slight_smile:

Hi @patrick.bussmann,

add this:
{
“locator”: “https://github.com/apache/cordova-plugin-camera”,
“id”: “cordova-plugin-camera”,
“variables”: {
“CAMERA_USAGE_DESCRIPTION”: “xx”
}
}

to your package.json at the cordovaPlugins section.

hope that helps

Thanks,
Daniel

1 Like

Remove the plugin and re-add it with the cordova plugin add cordova-plugin-camera --variable flags. This will update the Info.plist. Simply running ionic build ios --release does not update your plist, unfortunately.

Here was my command:

cordova plugin add cordova-plugin-camera --variable CAMERA_USAGE_DESCRIPTION=“CAMERA REASON” --variable PHOTOLIBRARY_USAGE_DESCRIPTION=“Photolibrary reason” --save

2 Likes

This should be the “accepted answer”, works perfectly!

Editing config.xml directly did NOT work for me because the config (JSON) files under platforms/ios didn’t get updated and hence also not the info.plist.

1 Like

I know I’m reviving and old thread but this is completely stupid. What is the point of having the variables in the package.json as well as the config.xml if they’re not re-imported at build time? We have to remove and re-add a plugin to change variables?? There has to be a better way.