9

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: one item


What I get: two items


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
Community
  • 1
  • 1
Jose
  • 234
  • 2
  • 13
  • Could try out this config: item 0 jp.star-m.starpro – Gandhi May 23 '16 at 07:59
  • Hi @Gandhi, that would give me an string inside an array, inside a dictionary all keyed with item 0. I tried it anyhow, but it didn't work. – Jose May 23 '16 at 14:51
  • How about using this plugin which simplifies your task - https://github.com/dpa99c/cordova-custom-config – Gandhi May 23 '16 at 14:56
  • Hi @Gandhi, that would probably work, anyhow I already found out how to write the `config-file`, thanks anyway. – Jose May 23 '16 at 16:15
  • Glad it worked but sad I missed out on the bounty. Was real close:( – Gandhi May 23 '16 at 16:17

2 Answers2

4

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 UISupportedExternalAccessoryProtocolsand remove the <key> tag and now works as expected.

Jose
  • 234
  • 2
  • 13
1

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.

Gandhi
  • 11,397
  • 4
  • 35
  • 56
  • That looks like a useful plugin for editing the info.plist from a cordova app, but (not sure if i missed it) how would I use this from a plugin? Because that is what I need. – Jose May 24 '16 at 15:16
  • @Jose its a plugin by itself used to manipulate the .plist file. Not sure whether i understood you question properly – Gandhi May 24 '16 at 16:11
  • What I need to do is modify the .plist file from a plugin, so I don't know how would I use this plugin from another plugin (the one I'm building) – Jose May 24 '16 at 17:29
  • @Jose if the only purpose of your custom plugin is jus to update .plist file, then u can use this readymade plugin instead of yours. If your custom plugin does anything more, then leave the .plist file updation to this plugin.But if u wanna use this inside your plugin, suggest you to look at file transfer plugin which uses file plugin as its dependent plugin. Hope it makes sense. – Gandhi May 24 '16 at 18:00
  • @Jose Thanks Jose. you made my day. Cheers – Gandhi May 26 '16 at 15:08