我正在使用visual studio开发cordova应用程序。
如果我使用Xcode8将我的应用程序上传到商店,我会收到以下错误邮件。
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.
根据其他stackoverflow问题,我添加了插件https://github.com/leecrossley/cordova-plugin-transport-security
并修改了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>
在我的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" />
之后我为iOS构建应用程序并通过xcode上传。
但错误仍然存在。
答案 0 :(得分:6)
通过该更改,您正在NSPhotoLibraryUsageDescription
内编写NSAppTransportSecurity
和其他UsageDescriptions,它应位于根目录下。
如果您使用最新版本的cordova-plugin-media-capture,它已经有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>
值为$CAMERA_USAGE_DESCRIPTION
,因为它是从您从CLI安装插件的变量中挑选出来的。当您使用Visual Studio时,我认为您可以使用config.xml中的变量标记来设置值。
变量标签应该在将使用它们的插件中:
<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>
如果这不起作用,您可以继续使用修改后的插件,但将每个UsageDescription添加为单独的config-file
标记,如上一代码所示。