Cordova custom plug-in, cordova custom
Cordova/phonegap custom plug-in
While using cordova, many open-source plug-ins are provided officially. However, sometimes you need to write your own plug-ins to meet certain requirements.
In the past, the cordova plug-in was always configured manually. For details, refer to phonegap manual configuration plug-in.
Today, we will introduce the official plug-in man to create plug-ins.
Use of pluman
First, install plumam
npm install -g plugman
After installation, you can create a plugin
plugman create --name <pluginName> --plugin_id <pluginID> --plugin_version <version> [--path <directory>] [--variable NAME=VALUE]
Parameters:
- PluginName: The name of the plugin
- PluginID: An ID for the plugin, ex: org. bar. foo
- Version: A version for the plugin, ex: 0.0.1
- Directory: An absolute or relative path for the directory where the plugin project will be created
- Variable NAME = VALUE: Extra variables such as description or Author
eg: plugman create --name HelloPlugin --plugin_id helloPlugin --plugin_version 0.0.1 ,
This command will create a HelloPlugin plug-in the current directory
Finally, if you want to add a plug-in to a project after development, you just need to jump to your project directory on the console as usual when adding a plug-in, and then run the following command:(Add is followed by the Directory of the plug-in)
cordova plugin add /Users/laozhuorun/Desktop/HelloPlugin
End
Now, a custom plug-in is created and added to the project.
You need to modify the plug-in after it is added to the project during development. After you delete the plug-in from the project, add the modified plug-in again.
Delete the plugin: cordova plugin remove XXXXX (your plugin_id ).
If you do not know the id of your plug-in, you can view it through the command line.
cordova plugin list