Prepare your workstation

The PhoneGap development environment and our example application requires a few tools to be installed. This lesson will get you ready to clone, build and run the app.

Install Git


Git is the easiest way to download the example application code. We'll also use it to fetch the Couchbase Lite PhoneGap Plugin. It's possible to get through these steps without Git, if you prefer.

Install the PhoneGap tools


The PhoneGap tools are implemented in Node.js and installed via the Node Package Manager.

  1. Install the latest version of Node.js . It should be greater than version 0.10, you can see which version of node you are using by running node -v.

  2. Use npm to install the PhoneGap tools by running npm install -g phonegap. Note the -g flag means "install globally" so it should install such that phonegap command is in your shell PATH. One consequence of this is that on certain systems, you might be required to prefix the install command with "sudo" before it can write to the global package store.

  3. Verify your PhoneGap installation is complete by running phonegap -v to print the version. At the time of this writing the version is 3.4.0-0.19.21.

Install the iOS platform tools.


The iOS tools are used by PhoneGap to compile and run your applications. (Or skip to the next section if you prefer Android.)

  1. Install Xcode. These docs are based on Xcode 5.

  2. Once Xcode is installed, several command-line tools need to be enabled for PhoneGap to run. From the Xcode menu, select Preferences, then the Downloads tab. From the Components panel, press the Install button next to the Command Line Tools listing.

  3. To launch your app on the simulator from PhoneGap you'll need ios-sim. The easiest way to install it is via Homebrew.

For additional information about setting up your iOS development environment, refer to the PhoneGap iOS Platform Guide.

Install the Android platform tools.


The Android tools are used by PhoneGap to compile and run your applications.

  1. Install Apache Ant.

  2. Install Android Studio.

  3. Install the Android SDK by using the Android SDK Manager. If you have a project open in Android Studio, you can run the SDK Manager by selecting Tools > Android > SDK Manager.

  4. Set up an Android emulator by using the Android AVD Manager. If you have a project open in Android Studio, you can run the AVD Manager by selecting Tools > Android > AVD Manager.

  5. Add paths to the Android SDK tools and platform tools to your system's PATH environment variable; for example, on Mac OS X add the following:

    /Applications/Android Studio.app/sdk/tools
    /Applications/Android Studio.app/sdk/platform-tools 
    

For additional information about setting up your Android development environment, refer to the PhoneGap Android Platform Guide.