简体   繁体   中英

Cordova: Modifying *-Info.plist from plugin.xml

I'm building a plugin to use star printers from an iOS device, with their SDK and everything is working fine except that config-file command to modify the info.plist file is not working properly. Inside my plugin.xml I have:

<config-file target="*-Info.plist" parent="Supported external accessory protocols">
  <array>
    <key>item 0</key>
    <string>jp.star-m.starpro</string>
  </array>
</config-file>

With that I should get a Supported external accessory protocols array with 1 item called item 0 , type String and value jp.star-m.starpro but instead I'm getting an array with two items as if I would have done:

<array>
    <key>item 0</key>
    <string>item 0</string>
    <key>item 1</key>
    <string>jp.star-m.starpro</string>
</array>

What I need: 一个项目


What I get: 两件事


Related questions:

I implemented the config-file by reading from this questions.

  1. Add entry to iOS .plist file via Cordova config.xml
  2. Two cordova plugins modifying “*-Info.plist” CFBundleURLTypes

After some further testing and research, I found out how to write the config-file to work properly. Here is the xml

<config-file target="*-Info.plist" parent="UISupportedExternalAccessoryProtocols">
    <array>
        <string>jp.star-m.starpro</string>
    </array>
</config-file>

Here, I changed the parent name from Supported external accessory protocols to UISupportedExternalAccessoryProtocols and remove the <key> tag and now works as expected.

You can check out this custom config plugin which should simply your task. This helps in manipulating *-info.plist file the way you intend to.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM