Reputation: 11
Sorry, my English is not very well. I'm using cordova 1.6.1. I created a new cordova-based project and I extended it to add a plugin.I build a static library with the plugin I created and try to run the projet including this library (the library can be found in the build settings of xcode), without the sources in the plugins folder
The following errors occur when I run my application :
[INFO] ClientChannel(1) initializing... CDVPlugin class MNClientChannelPlugin (pluginName: MNClientChannelPlugin) does not exist. ERROR: Plugin 'MNClientChannelPlugin' not found, or is not a CDVPlugin. Check your plugin mapping in Cordova.plist.
Some comments on these errors : 1) The first line is a log from The JavaScript code that I wrote, this indicates that the "initialize" function is launched. This function call a init function of a Plugin named MNClientChannelPlugin. 2) & 3) These logs come from the native iOS cordova sdk (Called from the getCommandInstance (2) and the execute (3) functions of CDVViewController.mm)
In the Codova.plist, I put MNClientChannelPlugin as a key and as a value. With this configuration, it works when I put MNClientChannelPlugin source (.mm & .h) in the Plugins folder but not when I created a static library with MNClientChannelPlugin.mm. (I included this library in my project and let the .h header in the Plugins folder). Cordova seems to doesn't find the source in the library...
The Cordova plugins are in the Cordova.Framework and not in the Plugins folder with .m and .h files so it seems possible to create plugins, package them in a library and use them in a cordova-based project but I it doesn't work for me... I have looked at the archives and the commits but did not find any solution. Does anyone know what could be the issue ?
Upvotes: 1
Views: 5266
Reputation: 2916
If you were using Pushwoosh (which I assume you were), the instructions clearly state that you should copy and paste this code:
<key>PushNotification</key>
<string>PushNotification</string>
to Plugins in “Cordova.plist. So if you have the above error which I once had it means that you did not copy and paste it to the Plugins. Moving the key and string values to the right location should annihilate the error.
Happy hacking!!!
Upvotes: 0
Reputation: 82237
Right, I've found a solution to this.
Here's the problem:
The solution is to force the linker to include the MNClientChannelPlugin object.
The easy was is to add -all_load to the 'other linker flags' for your main project. This will have the knock-on effect of linking every class in every static library in your project. It does work though.
The better was is to use -force_load with the name of your static library. Here's a post with help on this, though I haven't tried it myself:
xcode-project-target-settings-syntax-for-linker-flag-force-load-on-iphone
Upvotes: 1