Cordova:从plugin.xml修改*-Info.plist

Jos*_*ose 9 info.plist ios cordova cordova-plugins

我正在构建一个插件来使用iOS设备中的星形打印机,使用它们的SDK,一切正常,但config-file修改info.plist文件的命令无法正常工作.在我的plugin.xml里面,我有:

<config-file target="*-Info.plist" parent="Supported external accessory protocols">
  <array>
    <key>item 0</key>
    <string>jp.star-m.starpro</string>
  </array>
</config-file>
Run Code Online (Sandbox Code Playgroud)

有了这个我应该得到一个Supported external accessory protocols数组,其中包含一个名为item 0,类型String和值的项目,jp.star-m.starpro但我得到一个包含两个项目的数组,就好像我会做的那样:

<array>
    <key>item 0</key>
    <string>item 0</string>
    <key>item 1</key>
    <string>jp.star-m.starpro</string>
</array>
Run Code Online (Sandbox Code Playgroud)

我需要的: 一个项目


我得到了什么: 两件事


相关问题:

config-file通过阅读这些问题来实现.

  1. 通过Cordova config.xml向iOS .plist文件添加条目
  2. 修改"*-Info.plist"CFBundleURLTypes的两个cordova插件

Jos*_*ose 4

经过进一步的测试和研究,我找到了如何编写config-file才能正常工作。这是 XML

<config-file target="*-Info.plist" parent="UISupportedExternalAccessoryProtocols">
    <array>
        <string>jp.star-m.starpro</string>
    </array>
</config-file>
Run Code Online (Sandbox Code Playgroud)

在这里,我将父名称从 更改为Supported external accessory protocolsUISupportedExternalAccessoryProtocols删除了<key>标签,现在可以按预期工作。