user1469734
user1469734

Reputation: 801

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:

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.

Upvotes: 1

Views: 1802

Answers (3)

AMilassin
AMilassin

Reputation: 1196

I guess you have to do some manual work here. If it is a simple command you can create a "script" in the package.json and run it with "npm run script_name".

Depending on your specific needs you could also add a task to the gulpfile.js (this is used by the ionic build) or write a JS script which gets executed with a specific Cordova lifecycle step. Check this out for more details on this. The default Ionic project has an example hook you can check out for inspiration.

Upvotes: -1

Geo242
Geo242

Reputation: 597

I am the developer who initially contributed the iOS support and I don't see why you would need to do the configuration you mention more than once. Are you removing and adding the iOS platform from your project? That is the only thing that should cause that.

There are a few reasons that I didn't include the library in my original PR. But my reasoning could very well be flawed.

Here is what I was thinking...

  • I wasn't sure that including their library in another open source project complies with the Star software license.
  • Including the framework would forever obligate contributors to keep the framework up to date with releases from Star
  • There are multiple frameworks for iOS that will work with this plugin, one for regular bluetooth printers and one for the mPOP. So including one of the frameworks could limit the users ability to integrate with all possible platforms.

Regardless, the documentation should be improved to help other developers with the same issues.

Upvotes: 1

jcesarmobile
jcesarmobile

Reputation: 53301

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.

Upvotes: 3

Related Questions