Explore the process of creating an iOS cordova native plugin using Objective-C even if you have never touched native code. This quick guide is recommended for anyone interested in mobile hybrid app development, rapid prototyping using HTML5, CSS and JavaScript. Extend your app capabilities beyond web technology and utilize device sensors and API's to create a unique user mobile app experience. Enjoy!
4. Plugin development for iOS
Xcode IDE
iOS Device (recommended)
iOS simulator
Some familiarity with writing Objective-C code.
Some experience implementing Cocoa Touch API’s.
Cordova CLI must be installed.
Cordova Plugman must be installed.
A machine with Mac OSX installed.
Some Items you will need to get started for iOS native plugin development.
5. Configuring your plugin project
plugin.xml
The JavaScript interface
Objective-C source code
package.json
Publish your plugin
6. Creating a plugin project
Open terminal window and type in the following text. You can copy paste the text here into
your terminal and modify it.
plugman create --name testPlugin --plugin_id cordova-
plugin-openwith --plugin_version 0.0.1 --path
/Users/myname/Desktop/firstplugin
12. Create package.json
Copy paste the text below into your terminal and press enter. This will create a
package.json file into your root directory of your plugin project. Learn more about why this
file is needed on the cordova blog.
plugman createpackagejson /path/to/your/plugin
15. Testing your plugin
To test your plugin type out or copy paste the text into your terminal and press return. You
can modify the command to specify your native environment.
NOTE: While testing, plugins must be installed in the platform specific directory. See next
slide for example.
plugman install --platform ios –project
/path/to/your/app/platforms/ios --plugin
/path/to/my/plugin
17. Publish your plugin to NPM
// Enter the command below if you never published to the NPM
registry.
npm adduser
// Enter the command below after adding a user successfully
// you can also reuse this command to update your plugin
npm publish /path/to/your/plugin
// that’s it!!
After hours of debugging your native plugin and making sure it works in various scenarios.
You can now publish it to the NPM registry using the terminal command below.
18. Need help?
Cordova Plugin Development Guide
What else can Apache Cordova do?