0x6A75616E
0x6A75616E

Reputation: 4716

What is the workflow for developing PhoneGap 3.5.* plugins for ios?

I am developing a PhoneGap 3.5.0 app for iOS and Android. I want to write some functionality in native code and so I've been looking at creating a plugin.

I've followed the Plugin Development Guide and all of the code works fine; I can call native functions via the JS api the plugin exposes.

My question is how to continue development from here. Right now I just added the plugin classes manually to the project (I'm developing the plugin for iOS first, so I'm not concerned with android at this point). It looks like what I should be doing is put the plugin code in a separate repo that resembles this example and then add it to the app with the CLI tools.

I did this, and the plugin gets added to the app. However, I don't know how to continue making changes to the plugin, testing them, and also updating the plugin files in the app after they've changed in the plugin repo.

What's the intended/recommended workflow here? Is it to change the plugin files directly in the app from XCode and then copy them to the plugin repo every time?

Upvotes: 4

Views: 1007

Answers (1)

Eddy Verbruggen
Eddy Verbruggen

Reputation: 3550

I've been doing it more or less in the same way. I usually start a project with cordova create myplugintest, then cordova platform add ios and include one of my other plugins to have a kickstart cordova plugin add https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin for example. Then copy the plugin sources to the platform folder by running cordova prepare and see if all compiles correctly by running cordova build.

Then I start hacking away on the js and native code, creating my new plugin. When I'm happy, I create a new repo for the plugin, copy in an older plugin to get a starting point (mainly for the plugin.xml and the folder structure, so I don't make silly mistakes). Then copy in the files from myplugintest.

Then I throw away the myplugintest project and create a new one, this time adding the plugin from the new plugin repo. This serves two purposes: test whether or not the plugin and plugin.xml work as expected in a shiny new project. And also, this is the project I'll use to further expand the plugin when features need to be added. Once I'm happy with a change, I copy the specific change over to the plugin repo. This makes sure the plugin repo always contains working software (beta code is in the test project). It goes without saying you really need a good IDE with VCS integration to not loose track of your changes.

This may all sound a bit cucumbersome, but I personally don't have issues with this workflow.

As a sidenote - the plugin example you used is a good start, but not one with a lot of meat. It doesn't whow you how to return an error to the JS code (to trigger the errorcallback). Also, the plugin.xml has a js-modue tag inside a platform tag. While this may be valid in some cases, most of the time the js code is the same for all platforms, so it makes more sense to pull it up a level.

Upvotes: 3

Related Questions