Cordova: Modifying *-Info.plist from plugin.xml
Asked Answered
D

2

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
Dissipate answered 17/5, 2016 at 20:14 Comment(5)
Could try out this config: <config-file target="*-Info.plist" parent="Supported external accessory protocols"> <array> <dict> <key>item 0</key> <array> <string>jp.star-m.starpro</string> </array> </dict> </array> </config-file>Marbling
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.Dissipate
How about using this plugin which simplifies your task - github.com/dpa99c/cordova-custom-configMarbling
Hi @Gandhi, that would probably work, anyhow I already found out how to write the config-file, thanks anyway.Dissipate
Glad it worked but sad I missed out on the bounty. Was real close:(Marbling
D
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.

Dissipate answered 23/5, 2016 at 16:12 Comment(1)
Hey Jose, have you shared your plugin somewhere ? Github maybe ?Holiday
M
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.

Marbling answered 23/5, 2016 at 17:49 Comment(5)
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.Dissipate
@Dissipate its a plugin by itself used to manipulate the .plist file. Not sure whether i understood you question properlyMarbling
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)Dissipate
@Dissipate 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.Marbling
@Dissipate Thanks Jose. you made my day. CheersMarbling

© 2022 - 2024 — McMap. All rights reserved.