Aras
Aras

Reputation: 5926

How can I set linker options for a Cordova plugin?

I am developing a Cordova plugin that uses a custom ios SDK framework. The framework depends on two binary libraries: libcurl.a and boost.a. Right now during development I install the plugin in a test application like this:

cordova platform add ios
cordova plugin add my.cool.plugin

The binaries are included in the framework and get copied to the project that installs the plugin. However, some linker options are missing. To get the project to build, I have to open xcode and perform two additional manual step:

open platforms/ios/MyCoolProject.xcodeproj/

First, I have to add the two libraries to Link Binary With Libraries section in Build Phases:

enter image description here

Second, I have to add two linker flags (-lz -lstdc++) to Other linker flags section of the project default target. enter image description here

I certainly would like a cordova add plugin my.cool.plugin to be sufficient to install the plugin. So my question is, how can I automatically perform these tasks when the plugin gets installed?

Upvotes: 11

Views: 2166

Answers (2)

Raj Wilson Dsouza
Raj Wilson Dsouza

Reputation: 171

for -lz -lstdc++ just add this in the plugin xml and it will work.

<framework src="libstdc++.dylib" />
<framework src="libz.dylib" />

Upvotes: 3

Gapp
Gapp

Reputation: 1156

You can't set link flags (at the moment at least), however in this specific example the -lz actually just adds the libz.dylib. So to translate this to the Cordova plugin just add;

<framework src="libz.dylib" />

Upvotes: 0

Related Questions