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