简体   繁体   中英

Visual Studio Cordova Missing Info.plist key

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM