在Cordova iOS应用程序中将字段添加到info.plist [英] Add fields to info.plist in cordova ios app
问题描述
我需要创建自定义插件,以将条目添加到cordova/angular4 iOS应用程序的info.plist中. (在这种情况下,如果按下主页按钮,则退出应用程序)
I need to create custom plugin that will add entries to info.plist for cordova/angular4 iOS application. (In this case exit application if home button pressed)
我需要添加行:
<key>UIApplicationExitsOnSuspend</key>
<true/>
这是我编写的插件的内容(可能不正确,因为我无法对其进行测试).
Here is the content of plugin I wrote (which may be not correct, because I couldn't test it).
<config-file target="*-Info.plist" platform="ios" parent="UIApplicationExitsOnSuspend">
<array>
<boolean><true/></boolean>
</array>
</config-file>
将这个插件导入"到config.xml中需要什么,以便每次执行cordova build ios
plist文件都会有我需要的条目?
What is needed to 'import' this plugin to config.xml and so that every time I do cordova build ios
plist file will have entries I need?
我已经阅读了这篇文章,但我不知道它是如何完成的.
I've read this posts and I didn't understood how it's done.
通过Cordova将条目添加到iOS .plist文件config.xml
科尔多瓦:从plugin.xml修改* -Info.plist
推荐答案
经过几个小时的搜索和几次尝试,实际上只需添加:
After couple of hours of search and few attempts it was actually enough to just add:
<config-file target="*-Info.plist" parent="UIApplicationExitsOnSuspend">
<true/>
</config-file>
<config-file target="*-Info.plist" parent="UIApplicationExitsOnSuspend">
<true/>
</config-file>
(在我的情况下,这阻止了应用程序在后台运行)
(which in my case prevents application from running in the background)
直接进入 config.xml
,并将其嵌套在<platform name="ios">
标记中,就好像它是您的插件一样.并且此设置将在cordova build ios
期间添加到*-info.plist
,而无需手动安装您的自定义插件.
right into config.xml
and nest it inside <platform name="ios">
tag as if it was your plugin. And this setting will be added to *-info.plist
during cordova build ios
without any need to manually install your custom plugin.
提示:我首先被误认为,除了target="*-Info.plist"
中的*
之外,还必须有您应用的标题,但实际上它必须有一个*
符号和cordova本身会为您的应用程序找出info.plist的名称.
Hint: I was firstly mistaken that instead of *
in target="*-Info.plist"
there has to be your app's title, but as it happens there actually has to be a *
symbol and cordova itself will figure out the name of info.plist for you application.
这篇关于在Cordova iOS应用程序中将字段添加到info.plist的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!