Search code examples
cordovaionic-frameworkcordova-plugins

How do I integrate (3rd party) SDK via config.xml for Ionic/Cordova?


I'm using this plugin and integrated it as this demo-application did. That uses the Star SDK.

But how can I change something in my config.xml that the SDK is always added/loaded when I do an Ionic build? Because now we all have to re-add it to our project when we build from a different MacBook.

It's now specific for the StarIO SDK, but I think someone else maybe had the same struggle when adding an SDK.

Edit: Every time before I archive an iOS app from my Ionic project, I have to do the following manually:

  • Include framework and bundles (SDK) in my Xcode project
  • Link with some default framework/libraries like: ExternalAccessory.framework
  • Setup external accessory protocols in info.plist

This is lots of work, especially when we have multiple builds per week. And we don't always deploy on the same machine, and it's hard to forget a step.

I see this with a lot of Cordova packages, that you need to do some things manually when there is no Podfile, for example, or it always needs some configuration.


Solution

  • That's something StarIOPlugin creator should do instead of telling you to add the Star SDK manually. Start by adding an issue on StarIOPlugin's github repository.

    If the author doesn't want to do it, then you can fork the plugin and update it yourself.

    You should start by adding the StarIO.framework to the src/ios folder

    Now all you need can be done editing the plugin.xml file

    First add this line to the plugin.xml to copy the framework to the Xcode project

    <source-file src="src/ios/StarIO.framework" framework="true" />
    

    Then add this two lines to add Bluetooth and ExternalAccesory frameworks

    <framework src="CoreBluetooth.framework" />
    <framework src="ExternalAccesory.framework" />
    

    And finally, to write on the info.plist use

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

    I've not tested, but should be enough.