Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to create a PhoneGap plugin iOS

Does anyone have a simple example of how to create and test a custom PhoneGap iOS plugin because I can't get my plugin to get called no mater what I try?

like image 913
dorin Avatar asked Mar 25 '26 05:03

dorin


2 Answers

I would first suggest taking a look at the official Cordova iOS plugin guide found here:

http://cordova.apache.org/docs/en/latest/guide/platforms/ios/plugin.html

Make sure you are viewing the proper guide for the Cordova version you are developing for, sometimes it makes a difference.

Troubleshooting steps

iOS and PhoneGap can sometimes be very difficult to develop a plugin for. Sometimes for some reason it just doesn't work, especially after removing and re-adding plugins.

Make sure the plugin is properly listed in the config.xml file. If you are developing a plugin to work with Plugman, this required xml should automatically be inserted into the config.xml file. If not, you need to manually paste it into the config.xml.

Typically to get it working I usually run a project clean and build.

Open Xcode project -> hold down option key -> Select "Product" in menu bar -> Select "Clean Build Folder..."

I would also suggest factory resetting the iOS simulator

Open iOS sim ->  Menu Bar -> iOS Simulator -> Select "Reset Content and Settings..."

The best way to learn is to simply look at examples or existing plugins and see how they are doing it. I forked the old GitHub Cordova Plugin repository awhile ago, so I would suggest taking a look at some of the iOS plugins and use them as an example to build out your plugin. My fork can be found here

https://github.com/njtman/phonegap-plugins/tree/master/iOS

If you want more specific help I would suggest you editing your opening post with more details on the exact error you are receiving.

like image 80
njtman Avatar answered Mar 26 '26 20:03

njtman


I know its pretty late to reply for this post. But I would like to contribute to this question. I have written a blog to explain step by step process on how to create an iOS plugin for cordova. I believe someone would benefit with this tutorial.

https://subinworldblog.wordpress.com/2015/12/16/create-custom-ios-plugin-for-cordova/

like image 44
Subin Avatar answered Mar 26 '26 20:03

Subin



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!