【问题标题】:What is the Parent Tag for <edit-config in config,xml in cordova ios project?什么是 <edit-config in config,xml 在 cordova ios 项目中的父标签?
【发布时间】:2018-07-05 08:43:41
【问题描述】:

我更新了一个 iOS 应用,但被以下电子邮件拒绝

缺少 Info.plist 密钥 - 此应用尝试访问隐私敏感信息 没有使用说明的数据。应用的 Info.plist 必须包含 NSPhotoLibraryUsageDescription 键,带有解释为的字符串值 用户应用如何使用这些数据。

我尝试将以下 xml 标记添加到 config.xml。

<edit-config file="*-Info.plist" mode="merge" target="NSCameraUsageDescription">
    <string>Need camera access to take pictures</string>
</edit-config>
<edit-config file="*-Info.plist" mode="merge" target="NSPhotoLibraryUsageDescription">
    <string>Need to photo library access to get pictures from there</string>
</edit-config>

但我不确定我需要在哪个标签下

我的 config.xml 文件。

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.aotsinc.christian.iphone.biblequizcompanion" version="3.0.0" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>Bible Quiz Companion</name>
    <description>
        Bible Quiz Companion is a free app useful for the users to prepare for Jounior Bible Quiz Compatition.
    </description>
    <author email="dev@cordova.apache.org" href="http://cordova.io">
        Alpha Omega Tech Solutions Inc.
    </author>
    <content src="index.html" />
    <access origin="*" />
    <allow-intent href="http://*/*" />
    <allow-intent href="https://*/*" />
    <allow-intent href="tel:*" />
    <allow-intent href="sms:*" />
    <allow-intent href="mailto:*" />
    <allow-intent href="geo:*" />
    <platform name="android">
        <allow-intent href="market:*" />
    </platform>
    <platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
    </platform>
    <engine name="ios" spec="^4.5.4" />
    <plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
    <plugin name="cordova-plugin-x-socialsharing" spec="^5.2.1" />
    <plugin name="cordova-plugin-camera" spec="^4.0.1" />
    <plugin name="cordova-plugin-tts" spec="^0.2.3" />
    <plugin name="cordova-plugin-apprate" spec="^1.3.0" />
    <plugin name="com.darktalker.cordova.screenshot" spec="git+https://github.com/gitawego/cordova-screenshot.git" />
</widget>

感谢您的帮助

编辑 1

我尝试将您在 plugin.xml 中提供的代码添加到相机插件中,如下所示。但是我在 info.plist 中没有看到这个条目。你能告诉我我对plugin.xml 的更改是否正确。谢谢

<platform name="ios">
         <config-file target="config.xml" parent="/*">
             <feature name="Camera">
                 <param name="ios-package" value="CDVCamera" />
             </feature>
             <preference name="CameraUsesGeolocation" value="false" />
         </config-file>

         <js-module src="www/ios/CameraPopoverHandle.js" name="CameraPopoverHandle">
            <clobbers target="CameraPopoverHandle" />
         </js-module>

         <preference name="CAMERA_USAGE_DESCRIPTION" default=" " />
          <config-file target="*-Info.plist" parent="NSCameraUsageDescription">
               <string>Need camera access to take pictures</string>
          </config-file>
          <preference name="PHOTOLIBRARY_USAGE_DESCRIPTION" default=" " />
          <config-file target="*-Info.plist" parent="NSPhotoLibraryUsageDescription">
               <string>Need to photo library access to get pictures from there</string>
          </config-file>

         <header-file src="src/ios/UIImage+CropScaleOrientation.h" />
         <source-file src="src/ios/UIImage+CropScaleOrientation.m" />
         <header-file src="src/ios/CDVCamera.h" />
         <source-file src="src/ios/CDVCamera.m" />
         <header-file src="src/ios/CDVJpegHeaderWriter.h" />
         <source-file src="src/ios/CDVJpegHeaderWriter.m" />
         <header-file src="src/ios/CDVExif.h" />
         <framework src="ImageIO.framework" weak="true" />
         <framework src="CoreLocation.framework" />
         <framework src="CoreGraphics.framework" />
         <framework src="AssetsLibrary.framework" />
         <framework src="MobileCoreServices.framework" />
         <framework src="CoreGraphics.framework" />
         <framework src="AVFoundation.framework" />

     </platform>

【问题讨论】:

    标签: ios cordova cordova-plugins cordova-plugin-camera


    【解决方案1】:

    see docs

    在您的config.xml 作为&lt;platform name="ios"&gt; 的子节点添加:

    <edit-config target="NSPhotoLibraryUsageDescription" file="*-Info.plist" mode="merge">
        <string>need to photo library access to get pictures from there</string>
    </edit-config>
    

    【讨论】:

    • 这似乎不再起作用,从 cordova 8.xx 和 phonegap 8.x 开始,生成的 plist 只包含一个字符串条目,以 Privacy - 开头,并且不是应有的键值对。呃。
    【解决方案2】:

    PLUGIN.XML 文件中的 PLATFORM 标记下使用 config-file 而不是 edit-config需要这个的插件:

    <platform name="ios">
        <preference name="CAMERA_USAGE_DESCRIPTION" default=" " />
        <config-file target="*-Info.plist" parent="NSCameraUsageDescription">
             <string>Need camera access to take pictures</string>
        </config-file>
        <preference name="PHOTOLIBRARY_USAGE_DESCRIPTION" default=" " />
        <config-file target="*-Info.plist" parent="NSPhotoLibraryUsageDescription">
             <string>Need to photo library access to get pictures from there</string>
        </config-file>
    </platform>
    

    【讨论】:

    • 我尝试将您在 plugin.xml 中提供的 xml 代码添加到相机插件目录中。但是我在 info.plist 中没有看到这个新条目。你能告诉我我在 plugin.xml 中的更改是否正确。我以 EDIT 1 作为标题来编辑我的原始问题。谢谢
    • 您使用的是什么版本的相机插件和cordova?在最新版本的 cordova-plugin-camera 中,此配置已添加到 plugin.xml 中。https://github.com/apache/cordova-plugin-camera
    • 谢谢@Frix33,与cordova-plugin-contacts 有同样的问题,使用配置文件而不是编辑配置似乎有效。
    猜你喜欢
    • 2018-06-12
    • 2018-08-28
    • 1970-01-01
    • 2020-12-22
    • 1970-01-01
    • 2015-08-16
    • 1970-01-01
    • 1970-01-01
    • 2021-11-30
    相关资源
    最近更新 更多