Create your first app
This guide shows you how to create JS/HTML Cordova applications and publish them to different native mobile platforms by using the cordova
command line interface (CLI). Cordova command line detailed reference view [CLI Reference].
Install Cordova CLI
Cordova command line tools are distributed as npm packages.
Install the cordova
command line tool through these steps:
Download and install Node.js . After installation, you can use
node
and in the command linenpm
.(Optional) Download and install git client , if you don't have one. After the installation is successful, you can use it on the command line
git
. This command line is used to download resources in the git repository.Install the
cordova
module using Nodejsnpm
tools.cordova
The module will benpm
automatically downloaded by the tool.
On OS X and Linux:
$ sudo npm install -g cordova
On OS X and Linux, the
npm
commands are prefixedsudo
because theycordova
may need to be installed in other restricted directories such as/usr/local/share
. If you use the optional tool nvm/nave or have write access to the installation directory, then you can omit thesudo
prefix. Here are more tips to use when usingnpm
nosudo
prefix, if you want to do so.On Windows:
C:\>npm install -g cordova
-g
The sign tells npm
us to install globally cordova
. Otherwise we will install in a node_modules
subdirectory of the current working directory .
After the installation is complete, you should be able to run cordova
commands on the command line, and some help information will be printed without any parameters.
Create App
Jump to the directory where you maintain the source code and create your cordova project:
$ cordova create hello com.example.hello HelloWorld
This will create the necessary directories for your cordova application. By default, the cordova create
command generates the skeleton of a web-based application, and the home page of the project is a www/index.html
file.
Add platform
All subsequent commands need to be run in the project directory or any subdirectory of the project directory:
$ cd hello
Add the target platform to your App. We will add the'ios' and'android' platforms and make sure they are saved in config.xml
:
$ cordova platform add ios --save
$ cordova platform add android --save
contact us
QQ: 250187715
QQ group: 390736068