Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cordova plugin development workflow

Tags:

xcode

ios

cordova

When building an Hybrid iOS Cordova application (relying on Cordova CLI) I stumbled the need to build a custom plugin.

My workflow was the following:

  1. I scaffolded my Cordova plugin outside my Hybrid Application directory.
  2. Code it blindly (in Vim) and push to GitHub.
  3. Use cordova plugin rm and cordova plugin add to reinstall the plugin.
  4. Test.
  5. Repeat from step 2.

I deployed the plugin successfully in the product, however this process of coding Objective C blindly with Vim and doing a whole push to GitHub just to test it in my project feels awkward, however I couldn't find any information on the internet about a better workflow.

Ideally, this is the workflow I'd expect:

  1. Scaffold my plugin inside my application directory (maybe in plugins/ or in my custom src/) and publish when I'm ready to do so (or not publish closed-source plugins at all).
  2. Code the plugin using XCode.
  3. Reinstall the plugin from the local filesystem, this totally avoiding a separate repo/push.
  4. Test and iterate from step 2.

Is this workflow achievable?

like image 840
jviotti Avatar asked Nov 22 '25 00:11

jviotti


2 Answers

You could try the following workflow:

  1. have the plugin in a specific directory within the project
  2. have a grunt task that watches for changes in the above directory that copies the relevant files to the plugins directory and runs cordova prepare right after the copy step is complete
  3. edite and test...
like image 115
Vlad Stirbu Avatar answered Nov 24 '25 07:11

Vlad Stirbu


Personally, I've used the same approach, with a twist:

Step 1:

I've coded the boilerplate part of the plugin using Sublime Text (vim works as well :) )

Step 2:

cordova plugin add --link ../path_to_my_plugin

Step 3:

I can add the platforms/android to Android Studio (you should be able to do the same with platforms/ios)

Step 4:

Any changes to the native part are reflected in the original sources (because of the --link parameter), any changes needed to the js part of the plugin I can edit directly in the app directory itself

Step 5:

Commit and push the files in your original plugin directory

If you need to reconfigure some part of the boilerplate (plugin.xml configurations), I've just:

cordova plugin remove <plugin-name>

And then resumed from step 2

like image 29
andreimarinescu Avatar answered Nov 24 '25 07:11

andreimarinescu



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!