1 | ---
|
2 | title: CLI Reference
|
3 | description: Learn how to use Cordova CLI commands and their options.
|
4 | ---
|
5 |
|
6 |
|
7 | #
|
8 | # Licensed to the Apache Software Foundation (ASF) under one
|
9 | # or more contributor license agreements. See the NOTICE file
|
10 | # distributed with this work for additional information
|
11 | # regarding copyright ownership. The ASF licenses this file
|
12 | # to you under the Apache License, Version 2.0 (the
|
13 | # "License"); you may not use this file except in compliance
|
14 | # with the License. You may obtain a copy of the License at
|
15 | #
|
16 | # http://www.apache.org/licenses/LICENSE-2.0
|
17 | #
|
18 | # Unless required by applicable law or agreed to in writing,
|
19 | # software distributed under the License is distributed on an
|
20 | # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
21 | # KIND, either express or implied. See the License for the
|
22 | # specific language governing permissions and limitations
|
23 | # under the License.
|
24 | #
|
25 | -->
|
26 |
|
27 | # Cordova Command-line-interface (CLI) Reference
|
28 |
|
29 | ## Syntax
|
30 |
|
31 | ```bash
|
32 | cordova <command> [options] -- [platformOpts]
|
33 | ```
|
34 |
|
35 | ## Global Command List
|
36 |
|
37 | These commands are available at all times.
|
38 |
|
39 | | Command | Description
|
40 | |----------|--------------
|
41 | | create | Create a project
|
42 | | help <command> | Get help for a command
|
43 | | telemetry | Turn telemetry collection on or off
|
44 |
|
45 | ## Project Command List
|
46 |
|
47 | These commands are supported when the current working directory is a valid Cordova project.
|
48 |
|
49 | | Command | Description
|
50 | |--------------|--------------
|
51 | | info | Generate project information
|
52 | | requirements | Checks and print out all the installation requirements for platforms specified
|
53 | | platform | Manage project platforms
|
54 | | plugin | Manage project plugins
|
55 | | prepare | Copy files into platform(s) for building
|
56 | | compile | Build platform(s)
|
57 | | clean | Cleanup project from build artifacts
|
58 | | run | Run project (including prepare && compile)
|
59 | | serve | Run project with a local webserver (including prepare)
|
60 |
|
61 | ## Common options
|
62 |
|
63 | These options apply to all cordova-cli commands.
|
64 |
|
65 | | Option | Description
|
66 | |----------------------|------------------------
|
67 | | -d or --verbose | Pipe out more verbose output to your shell. You can also subscribe to `log` and `warn` events if you are consuming `cordova-cli` as a node module by calling `cordova.on('log', function() {})` or `cordova.on('warn', function() {})`.
|
68 | | -v or --version | Print out the version of your `cordova-cli` install.
|
69 | | --no-update-notifier | Will disable updates check. Alternatively set `"optOut": true` in `~/.config/configstore/update-notifier-cordova.json` or set `NO_UPDATE_NOTIFIER` environment variable with any value (see details in [update-notifier docs](https://www.npmjs.com/package/update-notifier#user-settings)).
|
70 | |--nohooks | Suppress executing hooks (taking RegExp hook patterns as parameters)
|
71 | | --no-telemetry | Disable telemetry collection for the current command.
|
72 |
|
73 | ## Platform-specific options
|
74 |
|
75 | Certain commands have options (`platformOpts`) that are specific to a particular platform. They can be provided to the cordova-cli with a '--' separator that stops the command parsing within the cordova-lib module and passes through rest of the options for platforms to parse.
|
76 |
|
77 | ## Examples
|
78 | - This example demonstrates how cordova-cli can be used to create a project with the `camera` plugin and run it for `android` platform. In particular, platform specific options like `--keystore` can be provided:
|
79 |
|
80 | # Create a cordova project
|
81 | cordova create myApp com.myCompany.myApp myApp
|
82 | cd myApp
|
83 | # Add camera plugin to the project and remember that in config.xml
|
84 | cordova plugin add cordova-plugin-camera --save
|
85 | # Add camera plugin to the project and remember that in config.xml. Use npm install to fetch.
|
86 | cordova plugin add cordova-plugin-camera --save --fetch
|
87 | # Add android platform to the project and remember that in config.xml
|
88 | cordova platform add android --save
|
89 | # Add android platform to the project and remember that in config.xml. Use npm install to fetch.
|
90 | cordova platform add android --save --fetch
|
91 | # Check to see if your system is configured for building android platform.
|
92 | cordova requirements android
|
93 | # Build the android and emit verbose logs.
|
94 | cordova build android --verbose
|
95 | # Run the project on the android platform.
|
96 | cordova run android
|
97 | # Build for android platform in release mode with specified signing parameters.
|
98 | cordova build android --release -- --keystore="..\android.keystore" --storePassword=android --alias=mykey
|
99 |
|
100 | ## cordova create command
|
101 |
|
102 | ### Synopsis
|
103 |
|
104 | Create the directory structure for the Cordova project in the specified path.
|
105 |
|
106 | ### Syntax
|
107 |
|
108 | ```
|
109 | cordova create path [id [name [config]]] [options]
|
110 | ```
|
111 |
|
112 | | Value | Description |
|
113 | |-------|---------------|
|
114 | | path | Directory which should not already exist. Cordova will create this directory. For more details on the directory structure, see below. |
|
115 | | id | _Default_: `io.cordova.hellocordova` <br/> Reverse domain-style identifier that maps to `id` attribute of `widget` element in `config.xml`. This can be changed but there may be code generated using this value, such as Java package names. It is recommended that you select an appropriate value. |
|
116 | | name | _Default_: `HelloCordova` <br/> Application's display title that maps `name` element in `config.xml` file. This can be changed but there may be code generated using this value, such as Java class names. The default value is `HelloCordova`, but it is recommended that you select an appropriate value. |
|
117 | | config | JSON string whose key/values will be included in `<path>`/.cordova/config.json |
|
118 |
|
119 | ### Options
|
120 |
|
121 | | Option | Description |
|
122 | |--------|-------------|
|
123 | | --template | Use a custom template located locally, in NPM, or GitHub. |
|
124 | | --copy-from\|--src | _Deprecated_ <br/> Use --template instead. Specifies a directory from which to copy the current Cordova project. |
|
125 | |--link-to | Symlink to specified `www` directory without creating a copy. |
|
126 |
|
127 | ### Directory structure
|
128 |
|
129 | Cordova CLI works with the following directory structure:
|
130 |
|
131 | ```
|
132 | myapp/
|
133 | |-- config.xml
|
134 | |-- hooks/
|
135 | |-- merges/
|
136 | | | |-- android/
|
137 | | | |-- windows/
|
138 | | | |-- ios/
|
139 | |-- www/
|
140 | |-- platforms/
|
141 | | |-- android/
|
142 | | |-- windows/
|
143 | | |-- ios/
|
144 | |-- plugins/
|
145 | |--cordova-plugin-camera/
|
146 | ```
|
147 |
|
148 | #### config.xml
|
149 |
|
150 | Configures your application and allows you to customize the behavior of your project. See also [config.xml reference documentation][config.xml ref]
|
151 |
|
152 | #### www/
|
153 |
|
154 | Contains the project's web artifacts, such as .html, .css and .js files. As a cordova application developer, most of your code and assets will go here. They will be copied on a `cordova prepare` to each platform's www directory. The www source directory is reproduced within each platform's subdirectory, appearing for example in `platforms/ios/www` or `platforms/android/assets/www`. Because the CLI constantly copies over files from the source www folder, you should only edit these files and not the ones located under the platforms subdirectories. If you use version control software, you should add this source www folder, along with the merges folder, to your version control system.
|
155 |
|
156 | #### platforms/
|
157 |
|
158 | Contains all the source code and build scripts for the platforms that you add to your project.
|
159 |
|
160 | > **WARNING:** When using the CLI to build your application, you should not edit any files in the /platforms/ directory unless you know what you are doing, or if documentation specifies otherwise. The files in this directory are routinely overwritten when preparing applications for building, or when plugins are re-installed.
|
161 |
|
162 | #### plugins/
|
163 |
|
164 | Any added plugins will be extracted or copied into this directory.
|
165 |
|
166 | #### hooks/
|
167 |
|
168 | This directory may contains scripts used to customize cordova-cli commands. Any scripts you add to these directories will be executed before and after the commands corresponding to the directory name. Useful for integrating your own build systems or integrating with version control systems.
|
169 |
|
170 | Refer to [Hooks Guide] for more information.
|
171 |
|
172 | #### merges/
|
173 |
|
174 | 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. A quick example, assuming a project structure of:
|
175 |
|
176 | ```
|
177 | merges/
|
178 | |-- ios/
|
179 | | -- app.js
|
180 | |-- android/
|
181 | | -- android.js
|
182 | www/
|
183 | -- app.js
|
184 | ```
|
185 |
|
186 | After building the Android and iOS projects, the Android application will contain both `app.js` and `android.js`. However, the iOS application will only contain an `app.js`, and it will be the one from `merges/ios/app.js`, overriding the "common" `app.js` located inside `www/`.
|
187 |
|
188 | #### Version control
|
189 |
|
190 | It is recommended not to check in `platforms/` and `plugins/` directories into version control as they are considered a build artifact. Instead, you should save the platform/plugin spec in the `config.xml` and they will be downloaded when on the machine when `cordova prepare` is invoked.
|
191 |
|
192 | ### Examples
|
193 |
|
194 | - Create a Cordova project in `myapp` directory using the specified ID and display name:
|
195 |
|
196 | cordova create myapp com.mycompany.myteam.myapp MyApp
|
197 |
|
198 | - Create a Cordova project with a symlink to an existing `www` directory. This can be useful if you have a custom build process or existing web assets that you want to use in your Cordova app:
|
199 |
|
200 | cordova create myapp --link-to=../www
|
201 |
|
202 |
|
203 | ## cordova platform command
|
204 |
|
205 | ### Synopsis
|
206 |
|
207 | Manage cordova platforms - allowing you to add, remove, update, list and check for updates. Running commands to add or remove platforms affects the contents of the project's platforms directory.
|
208 |
|
209 | ### Syntax
|
210 |
|
211 | ```bash
|
212 | cordova {platform | platforms} [
|
213 | add <platform-spec> [...] {--save | link=<path> | --fetch } |
|
214 | {remove | rm} platform [...] {--save | --fetch}|
|
215 | {list | ls} |
|
216 | check |
|
217 | save |
|
218 | update ]
|
219 | ```
|
220 |
|
221 | | Sub-command | Option | Description |
|
222 | ------------------------|-------------|------|
|
223 | | add `<platform-spec>` [...] | | Add specified platforms |
|
224 | | | --save | Save `<platform-spec>` into `config.xml` after installing them using `<engine>` tag |
|
225 | | | --link=`<path>` | When `<platform-spec>` is a local path, links the platform library directly instead of making a copy of it (support varies by platform; useful for platform development)
|
226 | | | --fetch | Fetches the platform using `npm install` and stores it into the apps `node_modules` directory |
|
227 | | remove `<platform>` [...] | | Remove specified platforms |
|
228 | | | --save | Delete specified platforms from `config.xml` after removing them |
|
229 | | | --fetch | Removes the platform using `npm uninstall` and removes it from the apps `node_modules` directory |
|
230 | | update `platform` [...] | | Update specified platforms |
|
231 | | | --save | Updates the version specified in `config.xml` |
|
232 | | | --fetch | Fetches the platform using `npm install` and stores it into the apps `node_modules` directory |
|
233 | | list | | List all installed and available platforms |
|
234 | | check | | List platforms which can be updated by `cordova-cli platform update` |
|
235 | | save | | Save `<platform-spec>` of all platforms added to config.xml |
|
236 |
|
237 | ### Platform-spec
|
238 |
|
239 | There are a number of ways to specify a platform:
|
240 |
|
241 | ```
|
242 | <platform-spec> : platform[@version] | path | url[#commit-ish]
|
243 | ```
|
244 |
|
245 | | Value | Description |
|
246 | |-----------|-------------|
|
247 | | platform | Platform name e.g. android, ios, windows etc. to be added to the project. Every release of cordova CLI pins a version for each platform. When no version is specified this version is used to add the platform. |
|
248 | | version | Major.minor.patch version specifier using semver |
|
249 | | path | Path to a directory or tarball containing a platform |
|
250 | | url | URL to a git repository or tarball containing a platform |
|
251 | | commit-ish | Commit/tag/branch reference. If none is specified, 'master' is used |
|
252 |
|
253 | ### Supported Platforms
|
254 |
|
255 | - Android
|
256 | - iOS
|
257 | - Windows (8.1, Phone 8.1, UWP - Windows 10)
|
258 | - Blackberry10
|
259 | - Ubuntu
|
260 | - Browser
|
261 |
|
262 | ### Deprecated Platforms
|
263 |
|
264 | - Amazon-fireos (use Android platform instead)
|
265 | - WP8 (use Windows platform instead)
|
266 | - Windows 8.0 (use older versions of cordova)
|
267 | - Firefox OS (use older versions of cordova)
|
268 |
|
269 | ### Examples
|
270 |
|
271 | - Add pinned version of the `android` and `ios` platform and save the downloaded version to `config.xml`:
|
272 |
|
273 | cordova platform add android ios --save
|
274 |
|
275 | - Add pinned version of the `android` and `ios` platform and save the downloaded version to `config.xml`. Install
|
276 | to the project using `npm install` and store it in the apps `node_modules` directory:
|
277 |
|
278 | cordova platform add android ios --save --fetch
|
279 |
|
280 | - Add `android` platform with [semver](http://semver.org/) version ^5.0.0 and save it to `config.xml`:
|
281 |
|
282 | cordova platform add android@^5.0.0 --save
|
283 |
|
284 | - Add platform by cloning the specified git repo and checkout to the `4.0.0` tag:
|
285 |
|
286 | cordova platform add https://github.com/myfork/cordova-android.git#4.0.0
|
287 |
|
288 | - Add platform using a local directory named `android`:
|
289 |
|
290 | cordova platform add ../android
|
291 |
|
292 | - Add platform using the specified tarball:
|
293 |
|
294 | cordova platform add ../cordova-android.tgz
|
295 |
|
296 | - Remove `android` platform from the project and from `config.xml`:
|
297 |
|
298 | cordova platform rm android --save
|
299 |
|
300 | - Remove `android` platform from the project and from `config.xml`. Run `npm uninstall` to remove it
|
301 | from the `node_modules` directory.
|
302 |
|
303 | cordova platform rm android --save --fetch
|
304 |
|
305 | - List available and installed platforms with version numbers. This is useful to find version numbers when reporting issues:
|
306 |
|
307 | cordova platform ls
|
308 |
|
309 | - Save versions of all platforms currently added to the project to `config.xml`.
|
310 |
|
311 | cordova platform save
|
312 |
|
313 | ## cordova plugin command
|
314 |
|
315 | ### Synopsis
|
316 |
|
317 | Manage project plugins
|
318 |
|
319 | ### Syntax
|
320 |
|
321 | ```bash
|
322 | cordova {plugin | plugins} [
|
323 | add <plugin-spec> [..] {--searchpath=<directory> | --noregistry | --link | --save | --browserify | --force | --fetch} |
|
324 | {remove | rm} {<pluginid> | <name>} --save --fetch |
|
325 | {list | ls} |
|
326 | search [<keyword>] |
|
327 | save |
|
328 | ]
|
329 | ```
|
330 |
|
331 | | Sub-command | Option | Description
|
332 | |------------------------|-------------|------
|
333 | | add `<plugin-spec>` [...] | | Add specified plugins
|
334 | | |--searchpath `<directory>` | When looking up plugins by ID, look in this directory and each of its subdirectories before hitting the registry. Multiple search paths can be specified. Use ':' as a separator in `*nix` based systems and ';' for Windows.
|
335 | | |--noregistry | Don't search the registry for plugins.
|
336 | | |--link | When installing from a local path, creates a symbolic link instead of copying files. The extent to which files are linked varies by platform. Useful for plugin development.
|
337 | | |--save | Save the `<plugin-spec>` as part of the `plugin` element into `config.xml`.
|
338 | | |--browserify | Compile plugin JS at build time using browserify instead of runtime.
|
339 | | |--force | _Introduced in version 6.1._ Forces copying source files from the plugin even if the same file already exists in the target directory.
|
340 | | |--fetch | Fetches the plugin using `npm install` and stores it into the apps `node_modules` directory |
|
341 | | remove `<pluginid>|<name>` [...]| | Remove plugins with the given IDs/name.
|
342 | | |--save | Remove the specified plugin from config.xml
|
343 | | |--fetch | Removes the plugin using `npm uninstall` and removes it from the apps `node_modules` directory |
|
344 | |list | | List currently installed plugins
|
345 | |search `[<keyword>]` [...] | | Search http://plugins.cordova.io for plugins matching the keywords
|
346 | |save | | Save `<plugin-spec>` of all plugins currently added to the project
|
347 |
|
348 | ### Plugin-spec
|
349 |
|
350 | There are a number of ways to specify a plugin:
|
351 |
|
352 | <plugin-spec> : [@scope/]pluginID[@version]|directory|url[#commit-ish][:subdir]
|
353 |
|
354 | | Value | Description
|
355 | |-------------|--------------------
|
356 | | scope | Scope of plugin published as a [scoped npm package]
|
357 | | plugin | Plugin id (id of plugin in npm registry or in --searchPath)
|
358 | | version | Major.minor.patch version specifier using semver
|
359 | | directory | Directory containing plugin.xml
|
360 | | url | Url to a git repository containing a plugin.xml
|
361 | | commit-ish | Commit/tag/branch reference. If none is specified, 'master' is used
|
362 | | subdir | Sub-directory to find plugin.xml for the specified plugin. (Doesn't work with `--fetch` option)
|
363 |
|
364 | ### Algorithm for resolving plugins
|
365 |
|
366 | When adding a plugin to a project, the CLI will resolve the plugin
|
367 | based on the following criteria (listed in order of precedence):
|
368 |
|
369 | 1. The `plugin-spec` given in the command (e.g. `cordova plugin add pluginID@version`)
|
370 | 2. The `plugin-spec` saved in `config.xml` (i.e. if the plugin was previously added with `--save`)
|
371 | 3. As of Cordova version 6.1, the latest plugin version published to npm that the current project can support (only applies to plugins that list their [Cordova dependencies] in their `package.json`)
|
372 | 4. The latest plugin version published to npm
|
373 |
|
374 | ### Examples
|
375 |
|
376 | - Add `cordova-plugin-camera` and `cordova-plugin-file` to the project and save it to `config.xml`. Use `../plugins` directory to search for the plugins.
|
377 |
|
378 | cordova plugin add cordova-plugin-camera cordova-plugin-file --save --searchpath ../plugins
|
379 |
|
380 | - Add `cordova-plugin-camera` with [semver](http://semver.org/) version ^2.0.0 and save it to `config.xml`:
|
381 |
|
382 | cordova plugin add cordova-plugin-camera@^2.0.0 --save
|
383 |
|
384 | - Add `cordova-plugin-camera` with [semver](http://semver.org/) version ^2.0.0 and `npm install` it. It will be stored in the `node_modules` directory:
|
385 |
|
386 | cordova plugin add cordova-plugin-camera@^2.0.0 --fetch
|
387 |
|
388 | - Clone the specified git repo, checkout to tag `2.1.0`, look for plugin.xml in the `plugin` directory, and add it to the project. Save the `plugin-spec` to `config.xml`:
|
389 |
|
390 | cordova plugin add https://github.com/apache/cordova-plugin-camera.git#2.1.0:plugin --save
|
391 |
|
392 | - Add the plugin from the specified local directory:
|
393 |
|
394 | cordova plugin add ../cordova-plugin-camera
|
395 |
|
396 | - Add the plugin from the specified tarball file:
|
397 |
|
398 | cordova plugin add ../cordova-plugin-camera.tgz --save
|
399 |
|
400 | - Remove the plugin from the project and the `config.xml`:
|
401 |
|
402 | cordova plugin rm camera --save
|
403 |
|
404 | - Remove the plugin from the project and `npm uninstall` it. Removes it from the `node_modules` directory:
|
405 |
|
406 | cordova plugin rm camera --fetch
|
407 |
|
408 | - List all plugins installed in the project:
|
409 |
|
410 | cordova plugin ls
|
411 |
|
412 | ### Conflicting plugins
|
413 | Conflicting plugins may occur when adding plugins that use `edit-config` tags in their plugin.xml file. `edit-config` allows plugins to add or replace attributes of XML elements.
|
414 |
|
415 | This feature can cause issues with the application if more than one plugin tries to modify the same XML element. Conflict detection has been implemented to prevent plugins from being added so one plugin doesn't try to overwrite another plugin's `edit-config` changes. An error will be thrown when a conflict in `edit-config` has been found and the plugin won't be added. The error message will mention that all conflicts must be resolved before the plugin can be added. One option to resolving the `edit-config` conflict is to make changes to the affected plugins' plugin.xml so that they do not modify the same XML element. The other option is to use the `--force` flag to force add the plugin. This option should be used with caution as it ignores the conflict detection and will overwrite all conflicts it has with other plugins, thus may leave the other plugins in a bad state.
|
416 |
|
417 | Refer to the [plugin.xml guide](https://cordova.apache.org/docs/en/latest/plugin_ref/spec.html#edit-config) for managing `edit-config`, resolving conflicts, and examples.
|
418 |
|
419 | ## cordova prepare command
|
420 |
|
421 | ### Synopsis
|
422 |
|
423 | Transforms config.xml metadata to platform-specific manifest files, copies icons & splashscreens,
|
424 | copies plugin files for specified platforms so that the project is ready to build with each native SDK.
|
425 |
|
426 | ### Syntax
|
427 |
|
428 | ```
|
429 | cordova prepare [<platform> [..]]
|
430 | [--browserify | --fetch]
|
431 | ```
|
432 |
|
433 | ###Options
|
434 |
|
435 | | Option | Description
|
436 | |------------|------------------
|
437 | | `<platform> [..]` | Platform name(s) to prepare. If not specified, all platforms are built.
|
438 | |--browserify | Compile plugin JS at build time using browserify instead of runtime.
|
439 | |--fetch | When restoring plugins or platforms, fetch will `npm install` the missing modules.
|
440 |
|
441 |
|
442 | ## cordova compile command
|
443 |
|
444 | ### Synopsis
|
445 |
|
446 | `cordova compile` is a subset of the [cordova build command](#cordova-build-command).
|
447 | It only performs the compilation step without doing prepare. It's common to invoke `cordova build` instead of this command - however, this stage is useful to allow extending using [hooks][Hooks guide].
|
448 |
|
449 | ###Syntax
|
450 |
|
451 | ```bash
|
452 | cordova build [<platform> [...]]
|
453 | [--debug|--release]
|
454 | [--device|--emulator|--target=<targetName>]
|
455 | [--buildConfig=<configfile>]
|
456 | [--browserify]
|
457 | [-- <platformOpts>]
|
458 | ```
|
459 | For detailed documentation see [cordova build command](#cordova-build-command) docs below.
|
460 |
|
461 | ## cordova build command
|
462 |
|
463 | ### Synopsis
|
464 |
|
465 | Shortcut for `cordova prepare` + `cordova compile` for all/the specified platforms. Allows you to build the app for the specified platform.
|
466 |
|
467 | ### Syntax
|
468 |
|
469 | ```bash
|
470 | cordova build [<platform> [...]]
|
471 | [--debug|--release]
|
472 | [--device|--emulator]
|
473 | [--buildConfig=<configfile>]
|
474 | [--browserify]
|
475 | [-- <platformOpts>]
|
476 | ```
|
477 |
|
478 | | Option | Description
|
479 | |------------|------------------
|
480 | | `<platform> [..]` | Platform name(s) to build. If not specified, all platforms are built.
|
481 | | --debug | Perform a debug build. This typically translates to debug mode for the underlying platform being built.
|
482 | | --release | Perform a release build. This typically translates to release mode for the underlying platform being built.
|
483 | | --device | Build it for a device
|
484 | | --emulator | Build it for an emulator. In particular, the platform architecture might be different for a device Vs emulator.
|
485 | | --buildConfig=`<configFile>` | Default: build.json in cordova root directory. <br/> Use the specified build configuration file. `build.json` file is used to specify paramaters to customize the app build process esecially related to signing the package.
|
486 | | --browserify | Compile plugin JS at build time using browserify instead of runtime
|
487 | | `<platformOpts>` | To provide platform specific options, you must include them after `--` separator. Review platform guide docs for more details.
|
488 |
|
489 | ### Examples
|
490 |
|
491 | - Build for `android` and `windows` platform in `debug` mode for deployment to device:
|
492 |
|
493 | cordova build android windows --debug --device
|
494 |
|
495 | - Build for `android` platform in `release` mode and use the specified build configuration:
|
496 |
|
497 | cordova build android --release --buildConfig=..\myBuildConfig.json
|
498 |
|
499 | - Build for `android` platform in release mode and pass custom platform options to android build process:
|
500 |
|
501 | cordova build android --release -- --keystore="..\android.keystore" --storePassword=android --alias=mykey
|
502 |
|
503 | ## cordova run command
|
504 |
|
505 | ### Synopsis
|
506 |
|
507 | Prepares, builds, and deploys app on specified platform devices/emulators. If a device is connected it will be used, unless an eligible emulator is already running.
|
508 |
|
509 | ###Syntax
|
510 |
|
511 | ```bash
|
512 | cordova run [<platform> [...]]
|
513 | [--list | --debug | --release]
|
514 | [--noprepare] [--nobuild]
|
515 | [--device|--emulator|--target=<targetName>]
|
516 | [--buildConfig=<configfile>]
|
517 | [--browserify]
|
518 | [-- <platformOpts>]
|
519 | ```
|
520 |
|
521 | | Option | Description
|
522 | |-------------|------------------
|
523 | | `<platform> [..]` | Platform name(s) to run. If not specified, all platforms are run.
|
524 | | --list | Lists available targets. Displays both device and emulator deployment targets unless specified
|
525 | | --debug | Deploy a debug build. This is the default behavior unless `--release` is specified.
|
526 | | --release | Deploy a release build
|
527 | | --noprepare | Skip preparing (available in Cordova v6.2 or later)
|
528 | | --nobuild | Skip building
|
529 | | --device | Deploy to a device
|
530 | | --emulator | Deploy to an emulator
|
531 | | --target | Deploy to a specific target emulator/device. Use `--list` to display target options
|
532 | | --buildConfig=`<configFile>` | Default: build.json in cordova root directory. <br/> Use the specified build configuration file. `build.json` file is used to specify paramaters to customize the app build process esecially related to signing the package.
|
533 | | --browserify | Compile plugin JS at build time using browserify instead of runtime
|
534 | | `<platformOpts>` | To provide platform specific options, you must include them after `--` separator. Review platform guide docs for more details.
|
535 |
|
536 | ###Examples
|
537 |
|
538 | - Run a release build of current cordova project on `android` platform emulator named `Nexus_5_API_23_x86`. Use the spcified build configuration when running:
|
539 |
|
540 | cordova run android --release --buildConfig=..\myBuildConfig.json --target=Nexus_5_API_23_x86
|
541 |
|
542 | - Run a debug build of current cordova project on `android` platform using a device or emulator (if no device is connected). Skip doing the build:
|
543 |
|
544 | cordova run android --nobuild
|
545 |
|
546 | - Run a debug build of current cordova project on an `ios` device:
|
547 |
|
548 | cordova run ios --device
|
549 |
|
550 | - Enumerate names of all the connected devices and available emulators that can be used to run this app:
|
551 |
|
552 | cordova run ios --list
|
553 |
|
554 |
|
555 | ## cordova emulate command
|
556 |
|
557 | ### Synopsis
|
558 |
|
559 | Alias for `cordova run --emulator`. Launches the emulator instead of device.
|
560 | See [cordova run command docs](#cordova-run-command) for more details.
|
561 |
|
562 | ## cordova clean command
|
563 |
|
564 | ### Synopsis
|
565 |
|
566 | Cleans the build artifacts for the specified platform, or all platforms by running platform-specific build cleanup.
|
567 |
|
568 | ### Syntax
|
569 |
|
570 | ```
|
571 | cordova clean [<platform> [...]]
|
572 | ```
|
573 |
|
574 | ### Example
|
575 |
|
576 | - Clean `android` platform build artifiacts:
|
577 |
|
578 | cordova clean android
|
579 |
|
580 |
|
581 | ## cordova requirements command
|
582 |
|
583 | ### Synopsis
|
584 |
|
585 | Checks and print out all the requirements for platforms specified (or all platforms added
|
586 | to project if none specified). If all requirements for each platform are met, exits with code 0
|
587 | otherwise exits with non-zero code.
|
588 |
|
589 | This can be useful when setting up a machine for building a particular platform.
|
590 |
|
591 | ### Syntax
|
592 |
|
593 | ```
|
594 | cordova requirements android
|
595 | ```
|
596 |
|
597 | ## cordova info command
|
598 |
|
599 | ### Synopsis
|
600 |
|
601 | Print out useful information helpful for submitting bug
|
602 | reports and getting help. Creates an info.txt file at the
|
603 | base of your project.
|
604 |
|
605 | ### Syntax
|
606 |
|
607 | ```
|
608 | cordova info
|
609 | ```
|
610 |
|
611 | ## cordova serve command
|
612 |
|
613 | ### Synopsis
|
614 |
|
615 | Run a local web server for www/ assets using specified `port` or default of 8000. Access projects at: `http://HOST_IP:PORT/PLATFORM/www`
|
616 |
|
617 | ### Syntax
|
618 |
|
619 | ```
|
620 | cordova serve [port]
|
621 | ```
|
622 |
|
623 | ## cordova telemetry command
|
624 |
|
625 | ### Synopsis
|
626 |
|
627 | Turns telemetry collection on or off.
|
628 |
|
629 | ### Syntax
|
630 |
|
631 | ```
|
632 | cordova telemetry [STATE]
|
633 | ```
|
634 |
|
635 | | Option | Description
|
636 | |-------------|------------------
|
637 | | on | Turn telemetry collection on.
|
638 | | off | Turn telemetry collection off.
|
639 |
|
640 | ### Details
|
641 | A timed prompt asking the user to opt-in or out is displayed the first time cordova is run.
|
642 | It lasts for 30 seconds, after which the user is automatically opted-out if he doesn't provide any answer.
|
643 | In CI environments, the `CI` environment variable can be set, which will prevent the prompt from showing up.
|
644 | Telemetry collection can also be turned off on a single command by using the `--no-telemetry` flag.
|
645 |
|
646 | ### Examples
|
647 | ```
|
648 | cordova telemetry on
|
649 | cordova telemetry off
|
650 | cordova build --no-telemetry
|
651 | ```
|
652 |
|
653 | For details, see our privacy notice: https://cordova.apache.org/privacy
|
654 |
|
655 | ## cordova help command
|
656 |
|
657 | ### Synopsis
|
658 |
|
659 | Show syntax summary, or the help for a specific command.
|
660 |
|
661 | ### Syntax
|
662 |
|
663 | ```
|
664 | cordova help [command]
|
665 | cordova [command] -h
|
666 | cordova -h [command]
|
667 | ```
|
668 |
|
669 | [Hooks guide]: http://cordova.apache.org/docs/en/latest/guide_appdev_hooks_index.md.html
|
670 | [config.xml ref]: http://cordova.apache.org/docs/en/latest/config_ref/index.html
|
671 | [Cordova dependencies]: http://cordova.apache.org/docs/en/latest/guide/hybrid/plugins/index.html#specifying-project-requirements
|
672 | [scoped npm package]: https://docs.npmjs.com/misc/scope
|