-
Notifications
You must be signed in to change notification settings - Fork 13
phonegap cli
The PhoneGap Command-line Interface (CLI) is a command-line tool for Windows, OS X, and Linux. It allows you to create, build, and install PhoneGap apps for each of the supported platforms. It can also utilize PhoneGap Build for those who don't have their local SDK setup!
For this workshop, we wouldn't be diving deep into the CLI. So, let's start off by installing it and creating our first project!
- Install node.js.
- Open Terminal.app or iTerm2.
- Tip: use Spotlight in find the app.
-
Install PhoneGap with the following command:
$ sudo npm install -g phonegap
Users who installed node.js into their user directory can discard sudo
. You
know who you are. If you aren't sure, then you probably need sudo.
-
Install Git (I recommend msysGit)
-
Open Command Prompt for node.js or Git Bash.
-
Install PhoneGap with the following command:
$ npm install -g phonegap
-
Open your favourite terminal.
-
Install PhoneGap with the following command:
$ npm install -g phonegap
Depending on how your package manager installed node.js, you may need to add
sudo
. You'll know because you'll receive an access denied error.
The PhoneGap CLI is used similar to other command-line tools.
While the PhoneGap CLI inherits from the Apache Cordova CLI, it does use different commands. This is annoying and will be changing very soon!
The PhoneGap CLI is very helpful. You can add help to any command to learn how to use it.
Let's look at an example:
$ phonegap help
$ phonegap --help
$ phonegap -h
All display:
Usage: phonegap [options] [commands]
Description:
PhoneGap command-line tool.
...
Examples:
$ phonegap help create
$ phonegap help remote build
$ phonegap create path/to/my-app
$ phonegap remote build android
And likewise to learn about create
:
$ phonegap help create
$ phonegap create help
$ phonegap create --help
$ phonegap create -h
All display:
Usage: phonegap create [options] <path> [id [name]]
Description:
Creates a new application at the provided path.
The application name and package ID can also be customized.
These values are set in the app manifest (www/config.xml) and are used when
creating a native project (platforms/<platform>/).
Options:
--name, -n <name> application name (default: "Hello World")
--id, -i <package> package name (default: "com.phonegap.hello-world")
Examples:
$ phonegap create path/to/my-app
$ phonegap create path/to/my-app "com.example.app" "My App"
$ phonegap create path/to/my-app --id "com.example.app" --name "My App"
The only help that help doesn't provide is about help. Yep.
- Type
$ phonegap help
to find the command to create a project.
- You'll notice that
$ phonegap create
is the command.
- Type
$ phonegap help create
to learn how to create a project. - Type
$ phonegap create my-app
to create a new project called My App. - Type
$ cd my-app/
to change into that app's directory.
Putting all of the command together, it would look like:
$ phonegap help
$ phonegap help create
$ phonegap create my-app
$ cd my-app/
Congratulations! You've created your first PhoneGap project!
Did you find a bug, quirk, or improvement? Please take a moment to submit a brief issue to phonegap/phonegap-cli/issues!
Thanks, you rock!