Ionic 应用程序未在 info plist 文件中显示各种权限,尽管它们位于 config.xml 中

Posted

技术标签:

【中文标题】Ionic 应用程序未在 info plist 文件中显示各种权限,尽管它们位于 config.xml 中【英文标题】:Ionic app not showing various permissions in info plist file despite them being in config.xml 【发布时间】:2018-12-18 01:19:14 【问题描述】:

我的config.xml 文件中有以下代码:

<platform name="ios">
        <allow-intent href="itms:*" />
        <allow-intent href="itms-apps:*" />
        <icon  src="resources/ios/icon/icon.png"  />
        <icon  src="resources/ios/icon/icon@2x.png"  />
        <icon  src="resources/ios/icon/icon-40.png"  />
        <icon  src="resources/ios/icon/icon-40@2x.png"  />
        <icon  src="resources/ios/icon/icon-40@3x.png"  />
        <icon  src="resources/ios/icon/icon-50.png"  />
        <icon  src="resources/ios/icon/icon-50@2x.png"  />
        <icon  src="resources/ios/icon/icon-60.png"  />
        <icon  src="resources/ios/icon/icon-60@2x.png"  />
        <icon  src="resources/ios/icon/icon-60@3x.png"  />
        <icon  src="resources/ios/icon/icon-72.png"  />
        <icon  src="resources/ios/icon/icon-72@2x.png"  />
        <icon  src="resources/ios/icon/icon-76.png"  />
        <icon  src="resources/ios/icon/icon-76@2x.png"  />
        <icon  src="resources/ios/icon/icon-83.5@2x.png"  />
        <icon  src="resources/ios/icon/icon-small.png"  />
        <icon  src="resources/ios/icon/icon-small@2x.png"  />
        <icon  src="resources/ios/icon/icon-small@3x.png"  />
        <icon  src="resources/ios/icon/icon-1024.png"  />
        <splash  src="resources/ios/splash/Default-568h@2x~iphone.png"  />
        <splash  src="resources/ios/splash/Default-667h.png"  />
        <splash  src="resources/ios/splash/Default-736h.png"  />
        <splash  src="resources/ios/splash/Default-Landscape-736h.png"  />
        <splash  src="resources/ios/splash/Default-Landscape@2x~ipad.png"  />
        <splash  src="resources/ios/splash/Default-Landscape@~ipadpro.png"  />
        <splash  src="resources/ios/splash/Default-Landscape~ipad.png"  />
        <splash  src="resources/ios/splash/Default-Portrait@2x~ipad.png"  />
        <splash  src="resources/ios/splash/Default-Portrait@~ipadpro.png"  />
        <splash  src="resources/ios/splash/Default-Portrait~ipad.png"  />
        <splash  src="resources/ios/splash/Default@2x~iphone.png"  />
        <splash  src="resources/ios/splash/Default~iphone.png"  />
        <splash  src="resources/ios/splash/Default@2x~universal~anyany.png"  />
        <config-file parent="NSPhotoLibraryUsageDescription" target="*-Info.plist">
            <string>This app requires access to your photos so you may upload them as meals or feed posts.</string>
        </config-file>
        <config-file parent="NSCameraUsageDescription" target="*-Info.plist">
            <string>This app requires access to your camera so you may upload photos as meals or feed posts.</string>
        </config-file>
        <config-file parent="NSPhotoLibraryAddUsageDescription" target="*-Info.plist">
            <string>This app requires access to your photos so you may upload them as meals or feed posts.</string>
        </config-file>
        <config-file parent="NSLocationAlwaysAndWhenInUseUsageDescription" target="*-Info.plist">
            <string>This app requires access to your location so that you can post where you are on the feed.</string>
        </config-file>
        <config-file parent="NSLocationWhenInUseUsageDescription" target="*-Info.plist">
            <string>This app requires access to your location so that you can post where you are on the feed.</string>
        </config-file>
    </platform>

我有各种过去一直有效的配置文件键值对......但由于某种原因,现在当我进行 iOS 构建时,这就是我的 plist 文件的样子:

它只显示照片库的条目,我的其他项目都没有。难道我做错了什么?我在网上查找的所有内容似乎都与我现在在 config.xml 中所做的完全一样。

【问题讨论】:

【参考方案1】:

您应该使用edit-config 而不是config-file,它允许使用merge 属性并允许您指定多个键

<edit-config file="*-Info.plist" mode="merge" target="NSCameraUsageDescription">
    <string>Explanation</string>
</edit-config>
<edit-config file="*-Info.plist" mode="merge" target="NSPhotoLibraryUsageDescription">
    <string>Explanation</string>
</edit-config>

【讨论】:

以上是关于Ionic 应用程序未在 info plist 文件中显示各种权限,尽管它们位于 config.xml 中的主要内容,如果未能解决你的问题,请参考以下文章

在 Ionic 项目中手动将 GoogleService-Info.plist 复制到哪里?

Ionic/Cordova Info.plist 丢失 CAMERA_USAGE_DESCRIPTION

IOS10 的 Ionic 框架 Plist

如何以编程方式访问 iOS 中其他已安装应用程序的 info.plist?

启动图像未在 iPhone 应用程序中加载

Flutter FCM Ios 未在设备上显示