缺少 PhoneGap plist.key

PhoneGap missing plist.key

当我尝试将我的 iTunes 应用程序安装程序上传到 iTunes 时,我消除了这个错误:

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.

Missing Info.plist key - This app attempts to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data.

我可以在下面的配置文件中添加什么来让它工作:

<preference name="permissions" value="none" />
    <preference name="orientation" value="default" />
    <preference name="target-device" value="universal" />
    <preference name="fullscreen" value="false" />
    <preference name="webviewbounce" value="false" />
    <preference name="disallowOverscroll" value="true" />
    <preference name="prerendered-icon" value="true" />
    <preference name="stay-in-webview" value="false" />
    <preference name="ios-statusbarstyle" value="black-opaque" />
    <preference name="detect-data-types" value="true" />
    <preference name="exit-on-suspend" value="false" />
    <preference name="show-splash-screen-spinner" value="true" />
    <preference name="auto-hide-splash-screen" value="true" />
    <preference name="disable-cursor" value="false" />
    <preference name="android-minSdkVersion" value="10" />
    <preference name="android-targetSdkVersion" value="19" />
    <preference name="android-installLocation" value="auto" />
    <gap:plugin name="org.apache.cordova.battery-status" source="npm" />
    <gap:plugin name="org.apache.cordova.camera" source="npm"/>    
    <gap:plugin name="org.apache.cordova.media-capture" source="npm"/>
    <gap:plugin name="org.apache.cordova.console" source="npm" />
    <gap:plugin name="org.apache.cordova.contacts" source="npm"/>

    <gap:plugin name="org.apache.cordova.device-motion" source="npm"/>
    <gap:plugin name="org.apache.cordova.device-orientation" source="npm"/>
    <gap:plugin name="org.apache.cordova.dialogs" source="npm"/>
    <gap:plugin name="org.apache.cordova.file" source="npm"/>
    <gap:plugin name="org.apache.cordova.file-transfer" source="npm"/>

    <gap:plugin name="org.apache.cordova.inappbrowser" source="npm"/>
    <gap:plugin name="org.apache.cordova.media" source="npm"/>
    <gap:plugin name="org.apache.cordova.network-information" source="npm"/>
    <gap:plugin name="org.apache.cordova.splashscreen" source="npm"/>
    <gap:plugin name="org.apache.cordova.vibration" source="npm"/>
    <icon src="icon.png" />

    <gap:splash src="splash.png" gap:platform="android" gap:qualifier="port-ldpi" />
    <gap:splash src="splash.png" gap:platform="android" gap:qualifier="port-mdpi" />
    <gap:splash src="splash.png" gap:platform="android" gap:qualifier="port-hdpi" />
    <gap:splash src="splash.png" gap:platform="android" gap:qualifier="port-xhdpi" />
    <gap:splash src="splash.png" gap:platform="blackberry" />
    <gap:splash src="splash.png" gap:platform="ios" width="320" height="480" />
    <gap:splash src="splash.png" gap:platform="ios" width="640" height="960" />
    <gap:splash src="splash.png" gap:platform="ios" width="640" height="1136" />
    <gap:splash src="splash.png" gap:platform="ios" width="768" height="1024" />
    <gap:splash src="splash.png" gap:platform="ios" width="1024" height="768" />
    <gap:splash src="splash.png" gap:platform="winphone" />
    <access origin="*" />

    <gap:plugin name=" phonegap-plugin-barcodescanner" source="npm" />
    <gap:plugin name="uk.co.workingedge.phonegap.plugin.launchnavigator" source="npm" />
    <gap:plugin name="cordova-plugin-directions" source="npm" />


    <!-- iPhone / iPod Touch  - lower 4s -->
    <icon src="icon-57.png" gap:platform="ios" width="57" height="57" />
    <icon src="icon.png" gap:platform="ios" width="114" height="114" />
    <icon src="icon-72.png" gap:platform="ios" width="72" height="72" />
    <icon src="152.png" gap:platform="ios" width="152" height="152" />
    <icon src="icon-120.png" gap:platform="ios" width="120" height="120" />
    <icon src="76.png" gap:platform="ios" width="76" height="76" />
    <icon src="icon-40.png" gap:platform="ios" width="40" height="40" />

    <!-- iPhone / iPod Touch - 5-5s -->
    <icon src="icon.png" gap:platform="ios" width="60" height="60" />
    <icon src="icon.png" gap:platform="ios" width="120" height="120" />
    <!-- iPhone6-6+ -->
    <icon src="icon.png" gap:platform="ios" width="180" height="180" />

    <!-- Settings Icon -->
    <icon src="icon-29.png" gap:platform="ios" width="29" height="29" />
    <icon src="icon.png" gap:platform="ios" width="58" height="58" />

    <!-- Spotlight Icon -->
    <icon src="icon.png" gap:platform="ios" width="40" height="40" />
    <icon src="icon.png" gap:platform="ios" width="80" height="80" />

    <plugin name="cordova-plugin-whitelist" version="1" source="npm"/>

    <gap:plugin name="cordova-plugin-geolocation" source="npm"/>

    <feature name="http://api.phonegap.com/1.0/battery" />
    <feature name="http://api.phonegap.com/1.0/camera" />
    <feature name="http://api.phonegap.com/1.0/network" />
    <feature name="http://api.phonegap.com/1.0/notification" />

    <gap:plugin name="cordova-plugin-x-socialsharing" source="npm" />

请在 xcode 中打开您的项目并转到资源文件夹中的 .plist 文件,

然后在 .plist 文件的末尾单击“+”并添加搜索“Privacy - Photo Library Usage Description”并将其值添加到旁边的列中。

请再次为“NSCameraUsageDescription”执行相同操作,然后单击“+”并搜索“Privacy - Camera Usage Description”并再次搜索在旁边的栏中给出一些用法说明。

它会解决你的问题。

欲了解更多信息,请访问以下内容:

1) 2) Official apple doc for all required keys to be added

另一个编辑: 大多数插件删除了使用说明的变量,所以现在设置它们的方式是使用 config.xml 中的 edit-config 标签,就像这样。

<edit-config target="NSCameraUsageDescription" file="*-Info.plist" mode="overwrite">
    <string>We are using the Camera for something...</string>
</edit-config>

但并非所有插件都已更新,所以最好先阅读插件的 README.md。在核心插件上,它位于名为 iOS Quirks.

的部分中

它还需要 cli 7.0.1 或更新版本,在 config.xml 中这样设置它:

<preference name="phonegap-version" value="cli-8.0.0" />

编辑:

如果您有 <preference name='phonegap-version' value='cli-7.0.1' />(或者如果您没有任何 phonegap-version,我的旧答案将不再有效,因为它将作为默认值使用)

要设置使用说明,请使用插件上的参数

<plugin name="cordova-plugin-camera">
   <param name="CAMERA_USAGE_DESCRIPTION" value="We are using the Camera for something..." />
   <param name="PHOTOLIBRARY_USAGE_DESCRIPTION" value="We are using the Photo Library for something..." />
</plugin>

请注意,如果您有一些具有相同用法描述的插件并且您没有用参数标签填充它们,它们可能会被替换为默认的空字符串

这个标签可以强制使用旧的builder,但是不推荐,新的builder更好 <preference name='pgb-builder-version' value='1' />

旧答案:

你可以在info.plist中这样写:

<gap:config-file platform="ios" parent="NSCameraUsageDescription" overwrite="true">
   <string>We are using the Camera for something...</string>
</gap:config-file>

overwrite="true"很重要,因为最新版本的相机插件已经写入空值。

我已经在示例应用程序上对其进行了测试并且它正在运行 https://github.com/jcesarmobile/phonegap-template-hello-world/blob/454e852955e66470890cba636450abd422f50598/config.xml#L153-L155

在访问 privacy-sensitive 相机、联系人等数据之前,您必须请求授权,当您访问 them.Then 时您的应用程序会崩溃 Xcode 将记录如下:

This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSContactsUsageDescription key with a string value explaining to the user how the app uses this data.

如何处理?正如苹果所说:

You must statically declare your app’s intended use of protected data classes by including the appropriate purpose string keys in your Info.plist file.

在您的情况下,您可能需要在 info.plist、

中添加以下内容

<!-- Photo Library --> <key>NSPhotoLibraryUsageDescription</key> <string>$(PRODUCT_NAME) photo use</string>

还建议您查看此 link 以获得更多详细信息。希望对你有帮助。

您还可以查看此 plugin,它有助于操作 *-info.plist

None 这里的答案完全适合我,所以我想我应该加两分钱来说明我是如何工作的。

首先,我尝试了接受的答案(jcesarmobile 写的那个)。当我尝试这个和 运行: phonegap build ios 每次配置从我的 config.xml 文件中删除。所以接下来我尝试了此处指示的解决方案:

http://geeklearning.io/how-to-add-specific-configuration-parameters-to-ios-p-list-and-android-manifest/

一开始这不起作用,必须进行一些更改,所有这些更改都是我从文件的 github 回购评论中获得的。我建议你 运行 构建,复制错误消息并在评论中搜索并按照他们说的做。一旦我重新构建它,它在上传 iTunes 连接时仍然没有工作。

最后我不得不打开 Info.plist 文件并手动输入以下内容

<key>NSCameraUsageDescription</key>
<string>We are using the Camera to (blah blah blah, your explanation)</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>We are using the Photo Library to (your reason)</string>
<key>NSMainNibFile</key>

尽管钩子并没有完全按照它声称的那样运行,但我仍然认为它很重要,因为在我这样做之前,所有内容都被删除了,现在它仍然存在。

我希望这对某人有所帮助。

Phonegap Build - 对于使用 cli-7.0.1 的任何人,现在可能每个人都应该这样做:

<edit-config target="NSPhotoLibraryUsageDescription" file="*-Info.plist" mode="overwrite">
    <string>Used to allow the user to select media to upload to us</string>
</edit-config>

那不在标签内,只是像其他所有内容一样在 Widget 标签内。将字符串更改为适合您的字符串。

在 ios 中你需要安装 camera-pluginbarcodescanner-plugin 之后你必须在 config.xml 中放置下面一行以覆盖 plist 文件。

<gap:plugin name="phonegap-plugin-barcodescanner" source="npm" />

<preference name="android-build-tool" value="gradle" />

<config-file platform="ios" target="*-Info.plist" parent="NSCameraUsageDescription">
    <string>It is used for scaning QR code.</string>
</config-file>

<edit-config platform="ios" target="*-Info.plist" parent="NSCameraUsageDescription" mode="merge">
    <string>It is used for scaning QR code.</string>
</edit-config>

<config-file platform="ios" target="*-Info.plist" parent="NSPhotoLibraryUsageDescription">
    <string>It is used for scanning QR code</string>
</config-file>

<edit-config platform="ios" target="*-Info.plist" parent="NSPhotoLibraryUsageDescription" mode="merge">
    <string>It is used for scanning QR code</string>
</edit-config>