Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Manually install Device plugin (and others) into cordova 3.0

Phonegap/Cordova 3.0 has moved into a modular design starting with version 3.0. For example, to call the device.version API, you need to include the Device plugin into your project.

Anyone can provide me with clear instructions on how to install the Device (or any other) cordova API plugin into a new iOS project (using XCode) AND Android (using Eclipse)?

All I could find is details using Node.js and/or PlugMan. Needing an automated script to do the basic job of adding a plugin is undesirable to me, as I do not like processes doing things I don't understand (behind the scene).

In the past (cordova 2.9), I did the following to add a third-party plugin in (say Android) that worked perfectly:

  1. Put the plugin .java code into the /src folder
  2. Put the plugin .js code in my www folder
  3. Import the .js file into index.html
  4. Add the feature tag in config.xml
  5. Call the plugin in Javascript

I never added plugins in iOS before.

However, I assumed the above process should work just fine for cordova-based plugins, but it did not. Up to this point, I did not try Android, but I tried iOS with no luck.

I included CDVDevice.h and CDVDevice.m in /plugins folder. Also I imported the device.js into index.html, and modified config.xml! I will try Android only after finishing iOS.

Please, if you know how to do this manually let me know.

Thank you in advance.

like image 363
d777 Avatar asked Jul 21 '13 23:07

d777


People also ask

Which command is used to install plugin in Cordova?

The cordova plugin add command requires you to specify the repository for the plugin code. Please note that when you follow the Web Project Dev workflow and use the CLI, the CLI will take care of adding the plugin code to the appropriate place for each platform.


1 Answers

You can do it this way, download the plugin locally to your machine then run this code

cordova plugin add <id located in plugin.xml> --searchpath <local path to plugin>

This will install the plugin into your project

like image 133
Rafael Amsili Avatar answered Nov 04 '22 12:11

Rafael Amsili