dejpig
Last Updated: February 25, 2016
·
10.52K
· g33konaut

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.

5 Responses
Add your response

11253

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?

over 1 year ago ·
11254

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...

over 1 year ago ·
11272

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.

over 1 year ago ·
13346

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.

over 1 year ago ·
14011

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?

over 1 year ago ·