Migration checklist for Cordova(Phonegap) application from version 2.x to 3.x

Written by - Saumya

27 February 2014

There might be chances that you are re-writing a project or simply maintainig an old codebase of a Cordova(phonegap) application. In both the cases, its ideal to go for the lastest version of the library. Being said that, its not that straight forward to migrate a phonegap 2.x application to Phonegap 3.x. And if, the project uses a 1.x version of jQuery with jQuerymobile, you might want to update that to 2.x too, which adds up to more confusion and work, than solution. I will be focusing on Cordova rather than Phonegap here. Yes, they are different! They are supposed to be the same but there are differences.

Here is a checklist to keep things in perspective.

Cordova

  • Get used to NodeJS. Yes, thats now mandatory to use.
  • Get used to Cordova and Phonegap, they are different.
  • Know the difference between Cordova and Phonegap, at-least what they do internally.
  • Read completely the getting started with Cordova.
  • Do not confuse with Web Project Dev work flow, if possible avoid it altogether.
  • Start with Native Platform Dev workflow. This is the one, which is closer to the older version workflow.
  • Do not use CLI for creating project. You can download the whole archive for a version as you used to in the previous versions and still can create project with it.
  • Get used to Plugman to manage plugins. Everything is now a plugin. That means, a default project created, is nothing more than a website. If you need to interact with a device, you have to add plugin. In Native Platform Dev, these are managed by Plugman.
  • For the first couple of trials, add all the plugins. That will make the project, behave as the older version projects, where everything is set by default. The document to install plugin is misleading.

Instead of

plugman --platform --project --plugin org.apache.cordova.battery-status

Use, the commands as below. The document is missing --install from the command!

plugman --install --platform --project --plugin org.apache.cordova.battery-status

The actual code will look as

plugman --install --ios --path/to/project/folder --plugin org.apache.cordova.battery-status

jQuery and jQueryMobile

  • Update the page change code to remove the deprecated one and use the new one.
  • Update the event listener code from deprecated live() to on().
  • Keep an eye on all the deprecated APIs of jQuery

That should make you compile your old project in the new code.

Happy transitioning.