Visual Studio Cordova Missing Info.plist key
Asked Answered
M

1

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.

Marauding answered 13/1, 2017 at 8:3 Comment(1)
check out the answer i have posted in the link - https://mcmap.net/q/1158640/-phonegap-missing-plist-key Looks like a similar issueGemmell
M
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.

Malony answered 18/1, 2017 at 11:21 Comment(2)
Thank you. At first, I tried it with adding the variable tag to the config.xml directly inside the <widget> 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. :)Marauding
@Marauding I edited the answer, the variable tag goes inside the plugin that uses it. If my answer helped you, you can accept the answerMalony

© 2022 - 2024 — McMap. All rights reserved.