11

I´m using visual studio for developing cordova applications.

If I upload my App to the Store with Xcode8, I get the following error mail.

Missing Info.plist key - This app attempts 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.

Based on an other stackoverflow-question I´ve added the plugin https://github.com/leecrossley/cordova-plugin-transport-security and modified the plugin.xml:

<platform name="ios"> <config-file target="*-Info.plist" parent="NSAppTransportSecurity"> <dict> <key>NSAllowsArbitraryLoads</key> <true/> <key>NSPhotoLibraryUsageDescription</key> <string>This app requires access to the photo library.</string> <key>NSMicrophoneUsageDescription</key> <string>This app does not require access to the microphone.</string> <key>NSCameraUsageDescription</key> <string>This app requires access to the camera.</string> </dict> </config-file> </platform>

In my config.xml:

<plugin name="cordova-plugin-transport-security" version="0.1.2" src="C:\Users\xxx\cordova-plugin-transport-security-master\cordova-plugin-transport-security-master" />

After that i build the app for iOS and uploaded it via xcode.

But the error is still there.

user6788419
  • 7,196
  • 1
  • 16
  • 28
alexander-fire
  • 1,082
  • 4
  • 27
  • 52
  • check out the answer i have posted in the link - http://stackoverflow.com/questions/41525725/phonegap-missing-plist-key Looks like a similar issue – Gandhi Jan 18 '17 at 13:26

1 Answers1

6

With that change you are writing the NSPhotoLibraryUsageDescription and the other UsageDescriptions inside NSAppTransportSecurity, it should be on the root.

If you use latest version of cordova-plugin-media-capture, it already have the needed values

        <preference name="CAMERA_USAGE_DESCRIPTION" default=" " />
        <config-file target="*-Info.plist" parent="NSCameraUsageDescription">
            <string>$CAMERA_USAGE_DESCRIPTION</string>
        </config-file>

        <preference name="MICROPHONE_USAGE_DESCRIPTION" default=" " />
        <config-file target="*-Info.plist" parent="NSMicrophoneUsageDescription">
            <string>$MICROPHONE_USAGE_DESCRIPTION</string>
        </config-file>

        <preference name="PHOTOLIBRARY_USAGE_DESCRIPTION" default=" " />
        <config-file target="*-Info.plist" parent="NSPhotoLibraryUsageDescription">
            <string>$PHOTOLIBRARY_USAGE_DESCRIPTION</string>
        </config-file>

The value is $CAMERA_USAGE_DESCRIPTION because it's picked from a variable whey you install the plugin from the CLI. As you use Visual Studio, I think you can set the value using a variable tag in the config.xml. The variable tags should be inside the plugin that will use them:

    <plugin name="cordova-plugin-media-capture" spec="~1.4.1">
        <variable name="CAMERA_USAGE_DESCRIPTION" value="your camera usage message" />
        <variable name="MICROPHONE_USAGE_DESCRIPTION" value="your microphone usage message" />
        <variable name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="your photolibrary usage message" />
    </plugin>

If that doesn't work, you can continue using your modified plugin, but add each UsageDescription as a separate config-file tag as in the previous code.

jcesarmobile
  • 51,328
  • 11
  • 132
  • 176
  • Thank you. At first, I tried it with adding the variable tag to the config.xml directly inside the `` tag. That doesn´t work. Should i place the variable tag in another hierarchy? After that, I replaced the variable in `plugin.xml` with a string. Now it works. :) – alexander-fire Jan 19 '17 at 07:30
  • @alexander-fire I edited the answer, the variable tag goes inside the plugin that uses it. If my answer helped you, you can accept the answer – jcesarmobile Jan 22 '17 at 18:25