Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova 3.1.0: Plugin not found or is not a CDVPlugin

I'm trying to build my first Cordova app and I can't get a plugin to work.

My app was built using the Cordova command line interface, so I've added the Camera plugin this way:

cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-camera.git

My config.xml looks like this:

<?xml version='1.0' encoding='utf-8'?>
<widget id="com.dev.myapp" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>My App</name>
    <description>
        A sample Apache Cordova application
    </description>
    <author email="[email protected]" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <access origin="*" />
    <preference name="fullscreen" value="true" />
    <preference name="webviewbounce" value="true" />
    <feature name="Camera">
        <param name="ios-package" value="CDVCamera" />
    </feature>
</widget>

I've run cordova build and everything went fine, but when I build the project in Xcode it tells me first the CDVCamera.h, CDVCamera.m files are missing. Isn't the command line interface supposed to place those files correctly when I run cordova plugin add in the first place ?

Also even if I copy the files manually in my project, the project runs but when I call the Camera functions it throws the following error:

ERROR: Plugin 'Camera' not found, or is not a CDVPlugin

I know I'm new to this, but I can't figure out what am i doing wrong ?

like image 259
picooose Avatar asked Oct 07 '13 09:10

picooose


5 Answers

If you still get this error when all files are in place, make sure the relevant source .m files are actually target members of the project.

To do so, select the Plugin.m file in Xcode and make sure that in the right inspector pane under Target Membership the checkbox for your project is checked.

I had this problem after removing and adding a plugin a few times.

Hint: the corresponding Plugin.h file lacks syntax color highlighting for types declared in the CDVPlugin classes when your plugin is not a project member (as observed in Xcode 5.0).

like image 81
jlapoutre Avatar answered Oct 23 '22 21:10

jlapoutre


If you don't have too much tied up in your Xcode project (which I didn't), the easiest way to resolve this is to do:

cordova platform remove ios

and then...

cordova platform add ios

Whatever it is that gets muddled up is resolved by doing that. You don't need to reinstall the plugins, they get installed when you re-add the platform.

like image 8
Chris Rae Avatar answered Oct 23 '22 21:10

Chris Rae


Ok so it seems you have to add all the plugins you want before you create the built. All the resources files are correctly located then.

like image 1
picooose Avatar answered Oct 23 '22 23:10

picooose


I had the same problem with phonegap 3.6. By updating phonegap, the problem is solved.

npm update -g cordova

Obviously, one must have the desire to update phonegap :)

like image 1
Pitbi Avatar answered Oct 23 '22 22:10

Pitbi


Let me just say I would try Chris Rae's solution of resetting your platform even if you don't think that's your issue!

cordova platform rm ios
cordova platform add ios

Thanks Chris Rae for your solution! It worked great for me. I gathered it and other solutions to problems I had while adding WKWebview to my app and put them in a blog post.

http://blog.tylerbuchea.com/using-wkwebview-in-ios9-to-boost-ionic-cordova-performance/

I think I took another one of your solutions about the build settings. So, don't be mad/thanks a bunch!

like image 1
Tyler Buchea Avatar answered Oct 23 '22 23:10

Tyler Buchea