Setup
Cordova 3.0
|
As all of you are aware that phonegap has released a new
version 3.0, which has incorporated architectural changes in it. And some of
the basic things like creating project, building project, adding platform
supports, adding PhoneGap API and adding Custom plug-in to the project has
changed.
Before you start the installation processes please go
through this link: Adobe-phonegap-3.0-released
Steps to Configure Cordova 3.0
|
1.
Make sure you install node.js in Mac/windows machine.
2. Once you have installednode.js , then open your command line and run the following:
C:\> npm install -g Cordova
2. Once you have installednode.js , then open your command line and run the following:
C:\> npm install -g Cordova
3.
Once installation completes, you can invoke Cordova on
command line for further help.
List of project command for Cordova
|
1.
To create a Cordova project
$ cordova create my-app # create a Cordova project
$ cordova create my-app # create a Cordova project
2.
Usage of Cordova commands
$ cordova [options] [commands]
$ cordova [options] [commands]
Commands:
I.
create <path> create a
phonegap project
II.
build <platform> build a
specific platform
III.
install <platform> install a
specific platform
IV.
run <platform> build and
install a specific platform
V.
local [command] development
on local system
VI.
remote [command] development in
cloud with phonegap/build
VII.
help [command] output usage
information
VIII.
version output
version number
Options:
I.
-V, --verbose allow
verbose output
II.
-v, --version output
version number
III.
-h, --help output
usage information
Examples:
I.
To Get the Cordova help type the following
command in command line.
$ Cordova help
II.
To create Cordova project, first locate the
project folder.
$ First redirect to you work space using the
cd/ls commands
$ Cordova create FirstApp
#Create a Cordova project
$ cd FirstApp #
Change the folder to app location
3.
Platforms Commands
$ “Cordova platform [ls | list]” list all platforms the project will build to $ “Cordova platform add <platform>
[<platform> ...]” add one (or more) platforms
as a build target for the project
$ “Cordova platform [rm | remove]
<platform> [<platform> ...]” removes
one (or more) platforms as a build target for the project
$ “Cordova platform [ls | list]” list all platforms the project will build to
4.
Plug-in Commands
$ “Cordova plugin [ls | list]” list all
plugins added to the project
$ “Cordova plugin add <path-to-plugin>
[<path-to-plugin> ...]” add one (or more)
plugins to the project
$”Cordova
plugin [rm | remove] <plugin-name> [<plugin-name> ...]” remove one (or more) added plugin’s
5.
Build Commands
$ “Cordova build” will build added platform projects like iOS,
android etc..
$ “Cordova build <android/ios etc..>” Will build the specific platform like iOS, Android ect
Project Directory Structure:
|
A Cordova application built with cordova-cli will have the
following directory structure:
.cordova/
This directory identifies a tree as a Cordova project.
Simple configuration information is stored in here (such as BlackBerry
environment variables).
Commands other than `create` operate against the project
directory itself, rather than the current directory - a search up the current
directory's parents is made to find the project directory. Thus, any command
(other than `create`) can be used from any subdirectory whose parent is a Cordova
project directory (same as git).
merges/
Platform-specific web assets (HTML, CSS and JavaScript
files) are contained within appropriate subfolders in this directory. These are
deployed during a `prepare` to the appropriate native directory. Files placed under `merges/` will override
matching files in the `www/` folder for the relevant platform.
www/
Contain the project resources such as .html, .css and .js
files. These are your main application assets. They will be copied on a
`cordova prepare` to each platform's www directory.
config.xml
This file is what you should be editing to modify your
application's metadata. Any time you run any cordova-cli commands, the tool
will look at the contents of `config.xml` and use all relevant info from this
file to define native application information. cordova-cli supports changing
your application's data via the following elements inside the `config.xml`
file:
platforms/
Platforms added to your application will have the native
application project structures laid out within this directory.
plugins/
Any added plugins will be extracted or copied into this
directory.
References
|