Cordova 3.1.0: Plugin not found or is not a CDVPlugin
Asked Answered
F

6

6

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 ?

Fez answered 7/10, 2013 at 9:49 Comment(0)
F
1

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.

Fez answered 8/10, 2013 at 8:57 Comment(0)
R
16

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).

Ruthie answered 31/10, 2013 at 18:53 Comment(4)
Thanks for this! I've had sooo much frustration over how finicky the command line tool is. It has a lot of little bugs that need to get worked out.Bouton
Thanks indeed! I've been trying to figure this out for a few hours now, you just saved me a lot of grief :)Flue
This works.. BUT.. how can you do this for cordova run ios (not via XCode)? I ask because I use (very useful!) ionic live-reload for rapid development, and I still haven't figured out if/how I can do live-reload using XCode.Sterner
just want to add, you can find these the list of .m files under build phases/compile sources. if you don't see your .m file for the plugin, you can try reinstalling it. that did the trick for my problem.Riotous
R
8

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.

Rollie answered 21/1, 2015 at 19:16 Comment(0)
F
1

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.

Fez answered 8/10, 2013 at 8:57 Comment(0)
T
1

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 :)

Terefah answered 13/4, 2015 at 9:2 Comment(0)
A
1

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!

Azurite answered 12/11, 2015 at 2:44 Comment(0)
S
0

I had this problem as well when reinstalling the plugin but managed to solve it. If, like me, removing the platform is not an option because you'd loose too much work, here's a solution:

Step 1: Add CDVCamera.m to your Compile Sources (Under Build Phases)

Step 2: If your problem is the same as mine, you'll get Apple Match-o-Linker errors: add the frameworks OpenAL and ImageIO to your project.

Step 3: Rebuild and rejoice :)

Shirtmaker answered 18/2, 2015 at 14:20 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.