Quickly create, test and build Phonegap/Cordova projects
Phonegap (or respectively Cordova) is really neat, when you wanna build hybrid mobile apps.
The biggest problem with it is the setup and usage - it takes pretty long until you can deploy your first application to a real device.
Gladly, there's the Cordova CLI wrapper in node.js!
$ npm install -g cordova
plus the SDK(s) for the platform(s) you want the app to be built on and you can create a new project for, let's say Android and iOS by running
$ cordova create DemoApp && cd DemoApp
$ cordova platform add ios android
to build your app, you just run
$ cordova build
Note: On iOS I had to manually build the Xcode project after this. Thanks, Apple.
And you find the results in build/<platform>/
.
You can also run the emulator / simulator with
$ cordova emulate
or serve the www
folder locally (via HTTP) with
$ cordova serve
That speeds up the setup process of new projects enormously.
Written by Martin Naumann
Related protips
5 Responses

When using cordova serve command you have to specify a <platform>, ie: cordova serve android will fire a local server running your android-specific www directory at http://localhost:8000/android/www/index.html. Do you know any way to serve the common www directory with the Cordova built-in server?

Well, depends on what you want to accomplish.
You can serve it with any static file server BUT you can't use any of the Phonegap APIs...

That's very interesting, I used Ripple Emulator some time ago to mock the Cordova API but I didn't know this built-in server was already doing the job.

Is there any command to quickly recreate changes. Currently when working with cordova serve all files are static and every change has to be generated again.

What's the right way to run the specs (in jasmine) via the CLI (or jasmine:ci)? Are there extra setup/config that needs to happen before you could do it?