另一个编辑:
大多数插件删除了使用描述的变量,所以现在设置它们的方式是使用edit-config
像这样在 config.xml 中标记。
<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" />
EDIT:
如果您有,我的旧答案将不再有效<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>
请注意,如果您有一些具有相同用法描述的插件,并且您没有使用参数标签填充它们,则它们可能会被替换为默认的空字符串
您可以强制使用带有此标签的旧构建器,但不推荐,新构建器更好<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>
The overwrite="true"
很重要,因为最新版本的相机插件已经在写入空值。
我已经在示例应用程序上对其进行了测试并且它正在工作https://github.com/jcesarmobile/phonegap-template-hello-world/blob/454e852955e66470890cba636450abd422f50598/config.xml#L153-L155 https://github.com/jcesarmobile/phonegap-template-hello-world/blob/454e852955e66470890cba636450abd422f50598/config.xml#L153-L155