I am new to the Cordova CLI.
我对科尔多瓦电力公司还不熟悉。
I need to perform the following steps programmatically via Cordova.
我需要以编程方式通过Cordova执行以下步骤。
- In the project .plist add a new row
- 在项目.plist中添加一个新行
- Enter the following values in the new row:
- 在新行中输入以下值:
- Key: GDLibraryMode Type:String (default) Value:GDEnterpriseSimulation
- 键:GDLibraryMode类型:String(默认)值:gdenterprisesulation
I think I need to do this in the config.xml file in my project's root (or maybe the one in the "platforms" folder).
我想我需要在配置中这样做。项目根目录中的xml文件(或者“平台”文件夹中的xml文件)。
Can someone explain to me how to add the entry via the config.xml so that the above entry is added at compile-time?
是否有人可以向我解释如何通过配置添加条目。xml以便在编译时添加上述条目?
I am using Cordova 3.3.1-0.42 (I know it is not the latest). I have already made my project and all is fine, I just need to add this entry added to the pList.
我正在用Cordova 3.1-0.42(我知道这不是最新的)。我已经完成了我的项目,一切正常,我只需要将这个条目添加到pList中。
12 个解决方案
#1
54
I don't think you can do this via straight config.xml
modification. At least, I didn't see any mention of this in the docs: http://cordova.apache.org/docs/en/3.3.0/config_ref_index.md.html
我不认为你可以通过直接配置来实现。xml修改。至少,我在文档中没有看到这一点:http://cordova.apache.org/docs/en/3.3.0/config_ref_index.md.html
I think you have to create a plugin, because they can insert plist entries: http://docs.phonegap.com/en/3.3.0/plugin_ref_spec.md.html#Plugin%20Specification
我认为你必须创建一个插件,因为他们可以插入plist条目:http://docs.phonegap.com/en/3.3.3.0 /plugin_ref_spec.md.html# plugin %20Specification
See the 'config-file element' section. Here's a guess as to what the relevant section of the plugin.xml
will look like:
参见“config-file元素”部分。下面是关于插件相关部分的猜测。xml的样子:
<platform name="ios">
<config-file target="*-Info.plist" parent="CFBundleURLTypes">
<array>
<dict>
<key>GDLibraryMode</key>
<string>GDEnterpriseSimulation</string>
</dict>
</array>
</config-file>
</platform>
Then you can install the plugin: cordova plugin add <your plugin name or file location>
然后你可以安装插件:cordova插件添加了 <你的插件名或文件位置>
#2
36
I really like @james's solution using a Cordova hook. However, there are two issues. The docs state:
我真的很喜欢用科尔多瓦钩来解决詹姆斯的问题。然而,有两个问题。文档状态:
- "we highly recommend writing your hooks using Node.js"
- “我们强烈建议您使用Node.js编写钩子。”
- "
/hooks
directory is considered deprecated in favor of the hook elements inconfig.xml
" - “/hooks目录被认为是不赞成的,以支持config.xml中的hook元素。”
Here's a Node.js implementation using the plist NPM package:
这是一个节点。使用plist NPM包实现js:
var fs = require('fs'); // nodejs.org/api/fs.html
var plist = require('plist'); // www.npmjs.com/package/plist
var FILEPATH = 'platforms/ios/.../...-Info.plist';
module.exports = function (context) {
var xml = fs.readFileSync(FILEPATH, 'utf8');
var obj = plist.parse(xml);
obj.GDLibraryMode = 'GDEnterpriseSimulation';
xml = plist.build(obj);
fs.writeFileSync(FILEPATH, xml, { encoding: 'utf8' });
};
Of all the hook types provided by Cordova, the relevant ones for your situation are:
在Cordova提供的所有类型中,与你的情况相关的是:
after_prepare
- after_prepare
before_compile
- before_compile
Choose a hook type, and then add the hook to your config.xml
file:
选择一个钩子类型,然后将钩子添加到配置中。xml文件:
<platform name="ios">
<hook type="after_prepare" src="scripts/my-hook.js" />
</platform>
#3
32
You can use the PlistBuddy utility inside a Cordova hook script to modify the *-Info.plist file.
您可以在Cordova钩子脚本中使用PlistBuddy实用程序来修改*-Info。plist文件。
For example, I have the following script under <project-root>/hooks/after_prepare/010_modify_plist.sh
which adds a dictionary property and adds an entry within that dictionary:
例如,我在
#!/bin/bash
PLIST=platforms/ios/*/*-Info.plist
cat << EOF |
Add :NSAppTransportSecurity dict
Add :NSAppTransportSecurity:NSAllowsArbitraryLoads bool YES
EOF
while read line
do
/usr/libexec/PlistBuddy -c "$line" $PLIST
done
true
Be sure to make the script executable (chmod +x
).
确保脚本可执行(chmod +x)。
The true
at the end of the script is because PlistBuddy
returns with an error exit code if the key being added already exists, and doesn't provide a way to detect if the key already exists. Cordova will report a build error if the hook script exits with an error status. Better error handling is possible but a pain to implement.
脚本末尾的真实情况是,如果添加的键已经存在,则PlistBuddy返回一个错误退出代码,并且不提供检测该键是否已经存在的方法。如果hook脚本以错误状态退出,Cordova将报告一个构建错误。更好的错误处理是可能的,但是执行起来很痛苦。
#4
13
This does seem to be possible now using the config.xml: at least some core plugin authors say so. For instance, in the docs for the Cordova Camera Plugin, they discuss the new requirement in iOS 10 that you provide a permission message string in the plist. To accomplish it, they suggest executing the plugin add command with arguments, thus:
现在使用配置似乎可以实现这一点。xml:至少有一些核心插件作者这么说。例如,在Cordova相机插件的文档中,他们讨论了ios10中新的要求,即在plist中提供权限消息字符串。为了实现这个目标,他们建议执行带有参数的插件add命令,因此:
cordova plugin add cordova-plugin-camera --variable CAMERA_USAGE_DESCRIPTION="My App would like to access your camera, to take photos of your documents."
corplugin dova添加了cordova-plugin-camera变量CAMERA_USAGE_DESCRIPTION=“我的应用程序想要访问您的相机,为您的文档拍照。”
This has the result that you not only get a new <plugin>
added to config.xml, but it has a <variable>
child:
这样做的结果是,您不仅得到一个新的
<plugin name="cordova-plugin-camera" spec="~2.3.0">
<variable name="CAMERA_USAGE_DESCRIPTION" value="My App would like to access your camera, to take photos of your documents." />
</plugin>
Which then seems to correlate to the new keys in my info.plist, perhaps somehow passing the values at runtime?
这似乎与我信息中的新键相关。plist,可能在运行时以某种方式传递值?
<key>NSCameraUsageDescription</key>
<string/>
<key>NSPhotoLibraryUsageDescription</key>
<string/>
I'd be lying if I said that I know exactly how it works, but it seems to point the way.
如果我说我知道它是怎么运作的,那我就是在撒谎,但它似乎为我指明了方向。
#5
10
These are the steps I ended up doing to enable my application to share files through itunes between devices.
这些是我最后完成的步骤,使我的应用程序能够通过itunes在设备之间共享文件。
1.In your application navigate to your config.xml. Type this piece into your config under the platform tag <platform name="ios">
.
1。在应用程序中导航到config.xml。在平台标签
<config-file platform="ios" target="*-Info.plist" parent="UIFileSharingEnabled">
<true/>
</config-file>
2. Then go to your command line tool and type: cordova prepare
2。然后使用命令行工具输入:cordova准备
- Uninstall and reinstall your application on your device, and you will see your app appear in itunes for you to share any files between your devices.
- 卸载并重新安装你的应用程序到你的设备上,你会看到你的应用程序出现在itunes中,你可以在你的设备之间共享任何文件。
A few things, make sure cordova is up to date, and that you added the platform for ios.
有几件事,确保cordova是最新的,并且你添加了ios平台。
npm install -g cordova
This command installs cordova.
这个命令安装科尔多瓦。
cordova platform add ios
This command adds the platform for ios.
该命令添加了ios平台。
What is happening is when you run the cordova prepare command you are using Apple's Xcode SDK that is generated in the platform/ios folder. There you can see the plist file that is generated for your application, which is labeled as "yourApp-info.plist". There you can see the new key and string produced in the xml layout which looks like this:
当您运行cordova准备命令时,您正在使用在platform/ios文件夹中生成的苹果Xcode SDK。在那里,您可以看到为应用程序生成的plist文件,它被标记为“yourApp-info.plist”。在那里,您可以看到在xml布局中生成的新键和字符串如下所示:
<key>UIFileSharingEnabled</key>
<true/>
Also word of warning, my company dropped this ionic framework application into my lap a couple weeks ago (with a really short deadline). Everything I am telling you is based on couple weeks of learning. So this may not be the best practice, but I hope it helps someone out.
还有一个警告,我的公司在几周前把这个ionic框架应用程序放到我的膝上(期限很短)。我告诉你的一切都是基于几周的学习。所以这可能不是最好的做法,但我希望它能帮助某些人。
#6
6
UPDATE: for people want to use camera with iOS >= 10. This mean, by normal you can config in plugin as:
更新:对于想要使用ios> = 10的人来说。这意味着,正常情况下你可以在插件中配置:
<!-- ios -->
<platform name="ios">
<config-file target="*-Info.plist" parent="NSLocationWhenInUseUsageDescription">
<string></string>
</config-file>
<config-file target="*-Info.plist" parent="NSCameraUsageDescription">
<string></string>
</config-file>
<config-file target="*-Info.plist" parent="NSPhotoLibraryUsageDescription">
<string></string>
</config-file>
</platform>
But for now, you can't config NSCameraUsageDescription
and NSPhotoLibraryUsageDescription
in plugin. You need to config them in platform -> iOS project by Xcode or in *-Info.plist
file.
但是现在,你不能在plugin中配置NSCameraUsageDescription和NSPhotoLibraryUsageDescription。您需要在平台-> iOS项目中通过Xcode或*- info配置它们。plist文件。
Since iOS 10 it's mandatory to add a NSCameraUsageDescription and NSPhotoLibraryUsageDescription in the info.plist.
由于iOS 10,所以必须在info.plist中添加nscameragedescription和NSPhotoLibraryUsageDescription。
Learn more: https://www.npmjs.com/package/cordova-plugin-camera
了解更多信息:https://www.npmjs.com/package/cordova-plugin-camera
#7
4
You can set the display name in app's plist by directly editing the ios.json in the plugins directory.
你可以通过直接编辑ios在app的plist中设置显示名。json在插件目录中。
Adding the following to the config_munge.files section of the ios.json file will do the trick and it will be maintained even when using the CLI.
向config_munge添加以下内容。ios的文件部分。json文件将执行这个技巧,即使在使用CLI时也会保持它。
"*-Info.plist": {
"parents": {
"CFBundleDisplayName": [
{
"xml": "<string>RevMob Ads Cordova Plugin Demo</string>",
"count": 1
}
]
}
}
Here's a complete example
这是一个完整的示例
#8
3
@TachyonVortex solution seems to be the best option but was crashing down in my case. The issue was caused by an empty NSMainNibFile field that is not right converted by the plist NPM package. In the .plist file
@TachyonVortex解决方案似乎是最好的选择,但在我的案例中失败了。这个问题是由一个空的NSMainNibFile字段引起的,该字段不被plist NPM包转换为正确的。在.plist文件
<key>NSMainNibFile</key>
<string></string>
<key>NSMainNibFile~ipad</key>
<string></string>
is converted to:
转化为:
<key>NSMainNibFile</key>
<string>NSMainNibFile~ipad</string>
I fixed it with by adding to the script:
我在剧本上加上:
obj.NSMainNibFile = '';
obj['NSMainNibFile~ipad'] = '';
The script finally looks like (scripts/my-hook.js):
脚本最终看起来像(脚本/my-hook.js):
var fs = require('fs'); // nodejs.org/api/fs.html
var plist = require('plist'); // www.npmjs.com/package/plist
var FILEPATH = 'platforms/ios/***/***-Info.plist';
module.exports = function (context) {
var xml = fs.readFileSync(FILEPATH, 'utf8');
var obj = plist.parse(xml);
obj.GDLibraryMode = 'GDEnterpriseSimulation';
obj.NSMainNibFile = '';
obj['NSMainNibFile~ipad'] = '';
xml = plist.build(obj);
fs.writeFileSync(FILEPATH, xml, { encoding: 'utf8' });
};
and config.xml:
和config . xml:
<platform name="ios">
<hook type="before_build" src="scripts/my-hook.js" />
</platform>
#9
2
I have used this plugin to solve the problem, maybe it can help you :
我用这个插件解决了这个问题,也许它可以帮助你:
https://www.npmjs.com/package/cordova-plugin-queries-schemes
https://www.npmjs.com/package/cordova-plugin-queries-schemes
#10
0
If you are trying to modify a .plist
in a native iOS plugin with a <config-file>
tag in your plugin.xml
, here is what you need to do:
如果您想在本地iOS插件中使用
-
Make sure your
.plist
is xml, not binary! You can useplutil
to convert a binary.plist
into xml, and commit it to version control.确保你的。plist是xml,不是二进制!您可以使用plutil将二进制.plist转换为xml,并将其提交到版本控制中。
plutil -convert xml1 Info.plist
plutil转换xml1 Info.plist
-
The instructions for
<config-file>
indicate thattarget=
is relative to the generated xcode project atplatforms/ios/<project>/
, but I found that I needed to prepend a wildcard character to my path to get it to work:的说明表明target=相对于在platform /ios/ /上生成的xcode项目,但是我发现我需要在我的路径前加上一个通配符才能让它工作: target="*/Resources/MyResources.bundle/Info.plist"
目标= " * /资源/ MyResources.bundle / Info.plist”
-
If you want to add a key at the top level of the
.plist
, you need to set parent equal to the key name, and then nest a<string>
tag with the value. Using an<array>
or<dict>
as any examples show will cause these keys to be nested underparent
.如果要在.plist的顶层添加一个键,需要将父键设置为键名,然后在
标记中嵌套该值。使用 或 ,因为任何示例都会导致这些键在父节点下嵌套。
Here is a complete example that works for me for adding multiple top level properties:
这里有一个完整的例子,可以帮助我添加多个*属性:
<platform name="ios">
<config-file target="*/Resources/MyResources.bundle/Info.plist" parent="MyDistribution">
<string>Cordova</string>
</config-file>
<config-file target="*/Resources/MyResources.bundle/Info.plist" parent="MyVersion">
<string>3.2.0</string>
</config-file>
</platform>
#11
0
I prefer the after_prepare hook for bigger projects or if you have multiple plugins using the same permissions. But you can always go the simple way:
我更喜欢after_prepare挂钩,用于大型项目,或者如果您有多个使用相同权限的插件。但你可以走简单的路:
simply: - remove the plugin that requires the desired permission - add it again with --save - in config.xml, the plugin now has a new variable with a blank description that you can fill in - now build ios with -- release and they will be set.
简单地说:-删除需要获得所需权限的插件-使用-save - in配置再次添加它。现在,这个插件有了一个新的变量,它有一个空白的描述,你可以用它来填充——现在用它来构建ios,然后它们就会被设置。
#12
-4
you just need following steps 1.
你只需要以下步骤1。
Go to Project navigator Select the target Click on info from tab option other option are build setting build phase you will see key type value When you point on any key name you will find + and - sign click on the + sign write
Key: GDLibraryMode
in key sectionType:String
in tyoe sectionValue:GDEnterpriseSimulation
in value section去项目导航器选择目标点击信息从其他选项选项卡选项构建构建阶段你会看到密钥类型值设置当你点任意键名字你会发现+和-点击加号标志写关键:在关键部分GDLibraryMode类型:Stringin tyoe部分价值:GDEnterpriseSimulation价值部分
#1
54
I don't think you can do this via straight config.xml
modification. At least, I didn't see any mention of this in the docs: http://cordova.apache.org/docs/en/3.3.0/config_ref_index.md.html
我不认为你可以通过直接配置来实现。xml修改。至少,我在文档中没有看到这一点:http://cordova.apache.org/docs/en/3.3.0/config_ref_index.md.html
I think you have to create a plugin, because they can insert plist entries: http://docs.phonegap.com/en/3.3.0/plugin_ref_spec.md.html#Plugin%20Specification
我认为你必须创建一个插件,因为他们可以插入plist条目:http://docs.phonegap.com/en/3.3.3.0 /plugin_ref_spec.md.html# plugin %20Specification
See the 'config-file element' section. Here's a guess as to what the relevant section of the plugin.xml
will look like:
参见“config-file元素”部分。下面是关于插件相关部分的猜测。xml的样子:
<platform name="ios">
<config-file target="*-Info.plist" parent="CFBundleURLTypes">
<array>
<dict>
<key>GDLibraryMode</key>
<string>GDEnterpriseSimulation</string>
</dict>
</array>
</config-file>
</platform>
Then you can install the plugin: cordova plugin add <your plugin name or file location>
然后你可以安装插件:cordova插件添加了 <你的插件名或文件位置>
#2
36
I really like @james's solution using a Cordova hook. However, there are two issues. The docs state:
我真的很喜欢用科尔多瓦钩来解决詹姆斯的问题。然而,有两个问题。文档状态:
- "we highly recommend writing your hooks using Node.js"
- “我们强烈建议您使用Node.js编写钩子。”
- "
/hooks
directory is considered deprecated in favor of the hook elements inconfig.xml
" - “/hooks目录被认为是不赞成的,以支持config.xml中的hook元素。”
Here's a Node.js implementation using the plist NPM package:
这是一个节点。使用plist NPM包实现js:
var fs = require('fs'); // nodejs.org/api/fs.html
var plist = require('plist'); // www.npmjs.com/package/plist
var FILEPATH = 'platforms/ios/.../...-Info.plist';
module.exports = function (context) {
var xml = fs.readFileSync(FILEPATH, 'utf8');
var obj = plist.parse(xml);
obj.GDLibraryMode = 'GDEnterpriseSimulation';
xml = plist.build(obj);
fs.writeFileSync(FILEPATH, xml, { encoding: 'utf8' });
};
Of all the hook types provided by Cordova, the relevant ones for your situation are:
在Cordova提供的所有类型中,与你的情况相关的是:
after_prepare
- after_prepare
before_compile
- before_compile
Choose a hook type, and then add the hook to your config.xml
file:
选择一个钩子类型,然后将钩子添加到配置中。xml文件:
<platform name="ios">
<hook type="after_prepare" src="scripts/my-hook.js" />
</platform>
#3
32
You can use the PlistBuddy utility inside a Cordova hook script to modify the *-Info.plist file.
您可以在Cordova钩子脚本中使用PlistBuddy实用程序来修改*-Info。plist文件。
For example, I have the following script under <project-root>/hooks/after_prepare/010_modify_plist.sh
which adds a dictionary property and adds an entry within that dictionary:
例如,我在
#!/bin/bash
PLIST=platforms/ios/*/*-Info.plist
cat << EOF |
Add :NSAppTransportSecurity dict
Add :NSAppTransportSecurity:NSAllowsArbitraryLoads bool YES
EOF
while read line
do
/usr/libexec/PlistBuddy -c "$line" $PLIST
done
true
Be sure to make the script executable (chmod +x
).
确保脚本可执行(chmod +x)。
The true
at the end of the script is because PlistBuddy
returns with an error exit code if the key being added already exists, and doesn't provide a way to detect if the key already exists. Cordova will report a build error if the hook script exits with an error status. Better error handling is possible but a pain to implement.
脚本末尾的真实情况是,如果添加的键已经存在,则PlistBuddy返回一个错误退出代码,并且不提供检测该键是否已经存在的方法。如果hook脚本以错误状态退出,Cordova将报告一个构建错误。更好的错误处理是可能的,但是执行起来很痛苦。
#4
13
This does seem to be possible now using the config.xml: at least some core plugin authors say so. For instance, in the docs for the Cordova Camera Plugin, they discuss the new requirement in iOS 10 that you provide a permission message string in the plist. To accomplish it, they suggest executing the plugin add command with arguments, thus:
现在使用配置似乎可以实现这一点。xml:至少有一些核心插件作者这么说。例如,在Cordova相机插件的文档中,他们讨论了ios10中新的要求,即在plist中提供权限消息字符串。为了实现这个目标,他们建议执行带有参数的插件add命令,因此:
cordova plugin add cordova-plugin-camera --variable CAMERA_USAGE_DESCRIPTION="My App would like to access your camera, to take photos of your documents."
corplugin dova添加了cordova-plugin-camera变量CAMERA_USAGE_DESCRIPTION=“我的应用程序想要访问您的相机,为您的文档拍照。”
This has the result that you not only get a new <plugin>
added to config.xml, but it has a <variable>
child:
这样做的结果是,您不仅得到一个新的
<plugin name="cordova-plugin-camera" spec="~2.3.0">
<variable name="CAMERA_USAGE_DESCRIPTION" value="My App would like to access your camera, to take photos of your documents." />
</plugin>
Which then seems to correlate to the new keys in my info.plist, perhaps somehow passing the values at runtime?
这似乎与我信息中的新键相关。plist,可能在运行时以某种方式传递值?
<key>NSCameraUsageDescription</key>
<string/>
<key>NSPhotoLibraryUsageDescription</key>
<string/>
I'd be lying if I said that I know exactly how it works, but it seems to point the way.
如果我说我知道它是怎么运作的,那我就是在撒谎,但它似乎为我指明了方向。
#5
10
These are the steps I ended up doing to enable my application to share files through itunes between devices.
这些是我最后完成的步骤,使我的应用程序能够通过itunes在设备之间共享文件。
1.In your application navigate to your config.xml. Type this piece into your config under the platform tag <platform name="ios">
.
1。在应用程序中导航到config.xml。在平台标签
<config-file platform="ios" target="*-Info.plist" parent="UIFileSharingEnabled">
<true/>
</config-file>
2. Then go to your command line tool and type: cordova prepare
2。然后使用命令行工具输入:cordova准备
- Uninstall and reinstall your application on your device, and you will see your app appear in itunes for you to share any files between your devices.
- 卸载并重新安装你的应用程序到你的设备上,你会看到你的应用程序出现在itunes中,你可以在你的设备之间共享任何文件。
A few things, make sure cordova is up to date, and that you added the platform for ios.
有几件事,确保cordova是最新的,并且你添加了ios平台。
npm install -g cordova
This command installs cordova.
这个命令安装科尔多瓦。
cordova platform add ios
This command adds the platform for ios.
该命令添加了ios平台。
What is happening is when you run the cordova prepare command you are using Apple's Xcode SDK that is generated in the platform/ios folder. There you can see the plist file that is generated for your application, which is labeled as "yourApp-info.plist". There you can see the new key and string produced in the xml layout which looks like this:
当您运行cordova准备命令时,您正在使用在platform/ios文件夹中生成的苹果Xcode SDK。在那里,您可以看到为应用程序生成的plist文件,它被标记为“yourApp-info.plist”。在那里,您可以看到在xml布局中生成的新键和字符串如下所示:
<key>UIFileSharingEnabled</key>
<true/>
Also word of warning, my company dropped this ionic framework application into my lap a couple weeks ago (with a really short deadline). Everything I am telling you is based on couple weeks of learning. So this may not be the best practice, but I hope it helps someone out.
还有一个警告,我的公司在几周前把这个ionic框架应用程序放到我的膝上(期限很短)。我告诉你的一切都是基于几周的学习。所以这可能不是最好的做法,但我希望它能帮助某些人。
#6
6
UPDATE: for people want to use camera with iOS >= 10. This mean, by normal you can config in plugin as:
更新:对于想要使用ios> = 10的人来说。这意味着,正常情况下你可以在插件中配置:
<!-- ios -->
<platform name="ios">
<config-file target="*-Info.plist" parent="NSLocationWhenInUseUsageDescription">
<string></string>
</config-file>
<config-file target="*-Info.plist" parent="NSCameraUsageDescription">
<string></string>
</config-file>
<config-file target="*-Info.plist" parent="NSPhotoLibraryUsageDescription">
<string></string>
</config-file>
</platform>
But for now, you can't config NSCameraUsageDescription
and NSPhotoLibraryUsageDescription
in plugin. You need to config them in platform -> iOS project by Xcode or in *-Info.plist
file.
但是现在,你不能在plugin中配置NSCameraUsageDescription和NSPhotoLibraryUsageDescription。您需要在平台-> iOS项目中通过Xcode或*- info配置它们。plist文件。
Since iOS 10 it's mandatory to add a NSCameraUsageDescription and NSPhotoLibraryUsageDescription in the info.plist.
由于iOS 10,所以必须在info.plist中添加nscameragedescription和NSPhotoLibraryUsageDescription。
Learn more: https://www.npmjs.com/package/cordova-plugin-camera
了解更多信息:https://www.npmjs.com/package/cordova-plugin-camera
#7
4
You can set the display name in app's plist by directly editing the ios.json in the plugins directory.
你可以通过直接编辑ios在app的plist中设置显示名。json在插件目录中。
Adding the following to the config_munge.files section of the ios.json file will do the trick and it will be maintained even when using the CLI.
向config_munge添加以下内容。ios的文件部分。json文件将执行这个技巧,即使在使用CLI时也会保持它。
"*-Info.plist": {
"parents": {
"CFBundleDisplayName": [
{
"xml": "<string>RevMob Ads Cordova Plugin Demo</string>",
"count": 1
}
]
}
}
Here's a complete example
这是一个完整的示例
#8
3
@TachyonVortex solution seems to be the best option but was crashing down in my case. The issue was caused by an empty NSMainNibFile field that is not right converted by the plist NPM package. In the .plist file
@TachyonVortex解决方案似乎是最好的选择,但在我的案例中失败了。这个问题是由一个空的NSMainNibFile字段引起的,该字段不被plist NPM包转换为正确的。在.plist文件
<key>NSMainNibFile</key>
<string></string>
<key>NSMainNibFile~ipad</key>
<string></string>
is converted to:
转化为:
<key>NSMainNibFile</key>
<string>NSMainNibFile~ipad</string>
I fixed it with by adding to the script:
我在剧本上加上:
obj.NSMainNibFile = '';
obj['NSMainNibFile~ipad'] = '';
The script finally looks like (scripts/my-hook.js):
脚本最终看起来像(脚本/my-hook.js):
var fs = require('fs'); // nodejs.org/api/fs.html
var plist = require('plist'); // www.npmjs.com/package/plist
var FILEPATH = 'platforms/ios/***/***-Info.plist';
module.exports = function (context) {
var xml = fs.readFileSync(FILEPATH, 'utf8');
var obj = plist.parse(xml);
obj.GDLibraryMode = 'GDEnterpriseSimulation';
obj.NSMainNibFile = '';
obj['NSMainNibFile~ipad'] = '';
xml = plist.build(obj);
fs.writeFileSync(FILEPATH, xml, { encoding: 'utf8' });
};
and config.xml:
和config . xml:
<platform name="ios">
<hook type="before_build" src="scripts/my-hook.js" />
</platform>
#9
2
I have used this plugin to solve the problem, maybe it can help you :
我用这个插件解决了这个问题,也许它可以帮助你:
https://www.npmjs.com/package/cordova-plugin-queries-schemes
https://www.npmjs.com/package/cordova-plugin-queries-schemes
#10
0
If you are trying to modify a .plist
in a native iOS plugin with a <config-file>
tag in your plugin.xml
, here is what you need to do:
如果您想在本地iOS插件中使用
-
Make sure your
.plist
is xml, not binary! You can useplutil
to convert a binary.plist
into xml, and commit it to version control.确保你的。plist是xml,不是二进制!您可以使用plutil将二进制.plist转换为xml,并将其提交到版本控制中。
plutil -convert xml1 Info.plist
plutil转换xml1 Info.plist
-
The instructions for
<config-file>
indicate thattarget=
is relative to the generated xcode project atplatforms/ios/<project>/
, but I found that I needed to prepend a wildcard character to my path to get it to work:的说明表明target=相对于在platform /ios/ /上生成的xcode项目,但是我发现我需要在我的路径前加上一个通配符才能让它工作: target="*/Resources/MyResources.bundle/Info.plist"
目标= " * /资源/ MyResources.bundle / Info.plist”
-
If you want to add a key at the top level of the
.plist
, you need to set parent equal to the key name, and then nest a<string>
tag with the value. Using an<array>
or<dict>
as any examples show will cause these keys to be nested underparent
.如果要在.plist的顶层添加一个键,需要将父键设置为键名,然后在
标记中嵌套该值。使用 或 ,因为任何示例都会导致这些键在父节点下嵌套。
Here is a complete example that works for me for adding multiple top level properties:
这里有一个完整的例子,可以帮助我添加多个*属性:
<platform name="ios">
<config-file target="*/Resources/MyResources.bundle/Info.plist" parent="MyDistribution">
<string>Cordova</string>
</config-file>
<config-file target="*/Resources/MyResources.bundle/Info.plist" parent="MyVersion">
<string>3.2.0</string>
</config-file>
</platform>
#11
0
I prefer the after_prepare hook for bigger projects or if you have multiple plugins using the same permissions. But you can always go the simple way:
我更喜欢after_prepare挂钩,用于大型项目,或者如果您有多个使用相同权限的插件。但你可以走简单的路:
simply: - remove the plugin that requires the desired permission - add it again with --save - in config.xml, the plugin now has a new variable with a blank description that you can fill in - now build ios with -- release and they will be set.
简单地说:-删除需要获得所需权限的插件-使用-save - in配置再次添加它。现在,这个插件有了一个新的变量,它有一个空白的描述,你可以用它来填充——现在用它来构建ios,然后它们就会被设置。
#12
-4
you just need following steps 1.
你只需要以下步骤1。
Go to Project navigator Select the target Click on info from tab option other option are build setting build phase you will see key type value When you point on any key name you will find + and - sign click on the + sign write
Key: GDLibraryMode
in key sectionType:String
in tyoe sectionValue:GDEnterpriseSimulation
in value section去项目导航器选择目标点击信息从其他选项选项卡选项构建构建阶段你会看到密钥类型值设置当你点任意键名字你会发现+和-点击加号标志写关键:在关键部分GDLibraryMode类型:Stringin tyoe部分价值:GDEnterpriseSimulation价值部分