• This repository has been archived on 11/Apr/2022
  • Stars
    star
    492
  • Rank 89,476 (Top 2 %)
  • Language
    JavaScript
  • License
    Apache License 2.0
  • Created about 12 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

PhoneGap and PhoneGap/Build command-line interface

PhoneGap CLI

Build StatusΒ  Build statusΒ codecov

PhoneGap command-line interface and Node.js library.

Command-line

Requirements

Install

$ npm install -g phonegap@latest

Getting Started

$ phonegap create my-app    # create a PhoneGap project
$ cd my-app                 # change to project directory
$ phonegap run ios          # build and install the app to iOS

Usage

Usage: phonegap [options] [commands]

Description:

  PhoneGap command-line tool.

Commands:

  create <path>        create a phonegap project
  build <platform>     build the project for specific platform
  install <platform>   install the project on a specific platform
  run <platform>       build and install the projectfor specific platform
  serve                serve a phonegap project
  local [command]      development on local system
  remote [command]     development in cloud with phonegap/build
  platform [command]   update a platform version
  help [command]       output usage information
  version              output version number
  analytics            turn analytics on or off, or view current status

Options:

  -d, --verbose        allow verbose output
  -v, --version        output version number
  -h, --help           output usage information

Platforms:

  keyword            | local environment | remote environment
  -------------------|-------------------|-------------------
  android            | βœ”                 | βœ”
  blackberry10       | βœ”                 | βœ–
  ios                | βœ”                 | βœ”
  wp8                | βœ”                 | βœ”


Examples:

  $ phonegap help create
  $ phonegap help remote build
  $ phonegap create path/to/my-app
  $ phonegap remote build android

Local Usage

Usage: phonegap local [command]

Description:

  Executes the command on the local system.

  This requires that platform SDK is correctly installed.

Commands:

  build <platform>     build a specific platform
  install <platform>   install a specific platform
  run <platform>       build and install a specific platform
  plugin <command>     add, remove, and list plugins

Examples:

  $ phonegap local build android
  $ phonegap local run android
  $ phonegap local plugin list

Remote Usage

Usage: phonegap remote [command]

Description:

  Executes the command remotely using the cloud-based PhoneGap/Build service.

Commands:

  login                login to PhoneGap/Build
  logout               logout of PhoneGap/Build
  build <platform>     build a specific platform
  install <platform>   install a specific platform
  run <platform>       build and install a specific platform

Examples:

  $ phonegap remote login
  $ phonegap remote build android
  $ phonegap remote run android

Node Library

Usage

var phonegap = require('phonegap');

App Templates

Templates allow you to create a new app from an existing app template. The nice part about templates is that they are simply a Cordova-compatible app. Any existing app can be a template.

You can list the available templates with:

$ phonegap template list

You can create a new project from a template with:

$ phonegap create my-app --template hello-world

Adding a New Template

Adding a new template is easy.

  1. Add your template to the package.json template section.

     // the key is your template name (e.g. hello-world)
     // the url is a HTTP URL to a .tar.gz.
     {
       "templates": {
         "hello-world": {
           "description": "Default hello world app for PhoneGap.",
           "url": "https://github.com/phonegap/phonegap-app-hello-world/archive/master.tar.gz"
         }
       }
     }
    
  2. Send us a pull request!

FAQ

phonegap: command not found

Problem

The PhoneGap CLI installs successfully but you do not have a command phonegap.

Reason

Depending on how node and npm were installed, your globally installed npm modules may not be in your PATH.

Solution

At the bottom of your npm install -g phonegap@latest installation log, you will see the following:

...
/usr/local/share/npm/bin/phonegap -> /usr/local/share/npm/lib/node_modules/phonegap/bin/phonegap.js
...

(Your path may be slightly different)

Open ~/.profile or ~/.bashrc, depending on what exists on your system, and add following line:

export PATH=$PATH:/usr/local/share/npm/bin

Open a new terminal tab or type the following command:

$ source ~/.profile
or
$ source ~/.bashrc

The command phonegap should now be available to you.

The provided path is not an Android project

Problem

You receive the following error message when building an Android project:

throw new Error('The provided path "' + project + '" is not an Android

Reason

The first time that you build for a platform, the framework is downloaded from Apache Cordova.

The framework is stored locally in your home directory, such as ~/.cordova/lib.

Sometimes the framework is corrupted during the download. It can exist for two know reasons:

  1. Your Android SDK environment is not properly configured.
  2. Unknown issue related to Apache's servers or the untar operation.

Solution

First, you must properly configure your Android environment by following the platform setup guide.

Next, you must delete the cached Cordova Android framework (x.x.x is your version):

~/.cordova/lib/android/cordova/x.x.x

Next, you can try to rebuild the project. Enabling verbose mode is sometimes helpful:

$ phonegap build android --verbose

Upgrading Cordova

There are a few steps that should be taken when upgrading to a new version of the cordova-cli.

  1. Update the package.json dependencies version for cordova.

     {
       "dependencies": {
         "cordova": "3.1.0"
       }
     }
    
  2. Update the package.json version.

     {
       "version": "3.1.0+cordova.0.15.0"
     }
    
  3. Run the tests.

     $ npm test
    
  4. Commit stating the version increment.

     $ git add package.json
     $ git commit -am "Version 3.1.0+cordova.0.15.0"
    
  5. Tag the version commit.

     $ git tag 3.1.0+cordova.0.15.0
    
  6. Update the PhoneGap Hello World App to match the new version.

  1. Manually test that the latest Hello World app is lazy-loaded.

     # Link the phonegap-cli for easier development (only need to do once).
    
     $ cd phonegap-cli/
     $ [sudo] npm link .
    
     # Manually test and verify hello world app is lazy-loaded.
    
     $ phonegap create my-app
     [phonegap] missing library phonegap/www/3.1.0
     [phonegap] downloading https://github.com/phonegap/phonegap-app-hello-world/archive/3.1.0.tar.gz...
     [phonegap] created project at /Users/mwbrooks/Development/sandbox/my-app
    
     $ cd my-app/
     $ phonegap run ios
    
  2. Push the git commit after the Hello World has been updated.

     $ git push phonegap master
    
  3. Publish the npm release.

     $ npm publish
    

Analytics

Please read our privacy policy for more information on the data we collect.

More Repositories

1

phonegap-start

PhoneGap Hello World app
JavaScript
3,427
star
2

phonegap-app-developer

PhoneGap Developer App
JavaScript
1,999
star
3

phonegap-plugin-push

Register and receive push notifications
Java
1,941
star
4

phonegap-plugin-barcodescanner

cross-platform BarcodeScanner for Cordova / PhoneGap
Objective-C++
1,271
star
5

phonegap-app-desktop

PhoneGap Desktop App
JavaScript
841
star
6

phonegap-plugin-contentsync

Download and cache remotely hosted content
C
206
star
7

phonegap-plugin-fast-canvas

Fast, 2D, mostly-HTML5-canvas-compatible rendering surface for Android.
C
195
star
8

phonegap-mobile-accessibility

PhoneGap plugin to expose mobile accessibility APIs.
JavaScript
145
star
9

phonegap-docs

PhoneGap Documentation
Pug
121
star
10

build

This is the public repository for PhoneGap Build source and bug tracking
92
star
11

phonegap-community

PhoneGap Community Release Notes
81
star
12

phonegap-template-react-hot-loader

PhoneGap Template using React, ES2015, Webpack, and hot module reloading
JavaScript
79
star
13

phonegap-template-hello-world

PhoneGap Hello World app
JavaScript
72
star
14

node-phonegap-build-api

Node.js REST Client for the PhoneGap Build API
JavaScript
62
star
15

connect-phonegap

Stream a PhoneGap app to any device.
JavaScript
61
star
16

phonegap-app-star-track

The PhoneGap media example app
CSS
54
star
17

phonegap-plugin-pwa

A plugin to provide progressive web app API's
45
star
18

phonegap-template-framework7

A starter template for creating a hybrid app with Framework7.
CSS
43
star
19

phonegap-app-anyconference

AnyConference example app
JavaScript
41
star
20

phonegap-2-style-3

PhoneGap 3.0 project that includes all of the plugins by default
JavaScript
39
star
21

phonegap-plugin-local-notification

An implementation of the Web Notifications API for end-user notifications.
Objective-C
38
star
22

phonegap-webview-ios

Native iOS + PhoneGap Template
Ruby
36
star
23

phonegap-plugin-media-stream

JavaScript
34
star
24

phonegap-template-vue-f7-blank

A blank PhoneGap template using Vue.js and Framework7
JavaScript
32
star
25

phonegap-template-vue-f7-tabs

A TabBar PhoneGap template using Vue.js and Framework7
JavaScript
31
star
26

phonegap-symbian.wrt

Symbian WRT implementation of the PhoneGap API
JavaScript
28
star
27

emulate.phonegap.com

Ripple emulation for PhoneGap's JavaScript environment
JavaScript
28
star
28

node-phonegap-build

PhoneGap Build node module to login, create, and build apps.
JavaScript
25
star
29

phonegap-sample-hybrid-ios

A sample application showing a hybrid application with both native and webview components and communication.
Objective-C
24
star
30

phonegap-sample-hybrid-android

Java
22
star
31

phonegap-app-fast-canvas

Example game using phonegap-fast-canvas-plugin
JavaScript
20
star
32

phonegap.github.io

Main pages for phonegap.com hosted on GitHub pages.
JavaScript
20
star
33

phonegap-plugin-multiview

Spawn multiple cordova enabled webviews in one app
JavaScript
18
star
34

phonegap-template-vue-f7-split-panel

A Split View PhoneGap template using Vue.js and Framework7 that degrades to a Panel View on smaller devices
JavaScript
16
star
35

phonegap-plugin-media-recorder

Objective-C
14
star
36

phonegap-plugin-image-capture

JavaScript
11
star
37

build-bot-model

PhoneGap Build Bot 3D model
11
star
38

phonegap-plugin-template

This repo is a template for starting a new plugin.
JavaScript
10
star
39

phonegap-template-push

A sample application for getting started with push notifications
JavaScript
8
star
40

app

The app showcase found at http://phonegap.github.io/app
HTML
7
star
41

app.phonegap.com

Micro-site for the PhoneGap Developer App and PhoneGap Desktop app.
JavaScript
7
star
42

phonegap-app-anyconference-pgday

AnyConference app for PhoneGap Day
JavaScript
7
star
43

phonegap-app-augmented-reality

CSS
6
star
44

phonegap-template-vue-f7-todos-pwa

A Todo's app template with PWA support using Vue.js and Framework7
JavaScript
6
star
45

adobe-creative-sdk-foundation

OBSOLETE - see README
4
star
46

phonegap-roadmap

Upcoming milestones and projects for PhoneGap
4
star
47

native-plugin-sync-demo

Demo of native-plugin-sync
CSS
4
star
48

phonegap-template-blank

A blank PhoneGap app.
HTML
3
star
49

book

http://phonegap.com/book/
HTML
3
star
50

workshop-plugins

Workshop / lab content covering end to end plugin development
3
star
51

phonegap-plugin-multidex

Enable multidex in a Apache Cordova/PhoneGap application
3
star
52

tool

A collection of 3rd party tools for PhoneGap development.
HTML
3
star
53

cordova-android

DO NOT DELETE - contains the thread-safe bridge code
Java
3
star
54

phonegap-app-stockpile

n. - A storage pile accumulated for future use
JavaScript
3
star
55

phonegap-day

The website for PhoneGap Day
JavaScript
2
star
56

phonegap-app-todo

JavaScript
2
star
57

linting-and-editorconfig

Reference repo for eslint (and other linters) as well as editorconfig settings and info
JavaScript
1
star
58

topcoat-preact

React components implementing Topcoat components
JavaScript
1
star
59

phonegap-template-webvr

PhoneGap template for the WebVR Boilerplate at https://github.com/borismus/webvr-boilerplate
JavaScript
1
star
60

dotfiles

A repo to collect the dot files we use consistently in our other repositories
1
star
61

phonegap-plugin-developer-mode

Utility functions for the Phonegap Developer app
JavaScript
1
star