Book Image

PhoneGap Beginners Guide (third edition)

Book Image

PhoneGap Beginners Guide (third edition)

Overview of this book

Table of Contents (22 chapters)
PhoneGap Beginner's Guide Third Edition
Credits
Foreword
About the Authors
About the Reviewers
www.PacktPub.com
Preface
Related Plugin Resources
Index

Installing dependencies


In order to be ready to build a PhoneGap app, it's mandatory to download and install the latest SDKs for each target platform of the app from the respective official websites:

Each of the preceding platform SDKs have their own setup configuration and it's advised to refer to the respective websites for updated information. To use several IDEs, such as NetBeans, Eclipse, or JBoss Developer Studio, we need Java to be available.

Java JDK

You need to install the most recent Java JDK (not just the JRE). Next, create an environment variable for JAVA_HOME, pointing to the root folder where the Java JDK was installed. For example, if your installation path is C:\Program Files\Java\jdk7, set JAVA_HOME to be this path. After that, add the JDK's bin directory (C:\Program Files\Java\jdk7\bin) to the PATH variable as well.

Apache Ant

We need Apache Ant to be installed and configured. Update your PATH to include the bin folder in the installation folder. For advanced configuration details, visit http://ant.apache.org/manual/index.html.

Due to the latest changes in the PhoneGap framework, it's always suggested to use the command-line interface to create a new project, update the framework, or install plugins. To work with the command line, we will need the Node.js application. To start with, download and install Node.js from http://nodejs.org. Once you have done this, you should be able to verify the installation by invoking npm or node on your command line. You may need to add the npm directory to your system PATH in order to invoke globally-installed npm modules.

At the end of every installation, you should be able to verify the installations of each package with the following commands:

android list sdk
javac –version
ant –version
node -v

If any of the preceding command lines don't work as required, you might need to revisit your system PATH settings. For example, PhoneGap and Cordova require the ANDROID_HOME environment variable to be set in PATH. This should point to the [ANDROID_SDK_DIR]\android-sdk directory (for example, c:\android\android-sdk).

Next, update your PATH to include the tools/ and platform-tools/ folders. So, using ANDROID_HOME, you would add both %ANDROID_HOME%\tools and %ANDROID_HOME%\platform-tools.

For OS X users, it is also important to install ios-sim. The ios-sim tool is a command-line utility that launches an iOS app on the simulator. To install the tool, you can again use npm, as shown here:

npm install –g ios-sim

Depending on your privileges, you may have to run the npm command as an administrator (that is, adding sudo before the npm command).

Once the SDKs are installed, it's recommended that you also install the client for GitHub. GitHub is a social coding platform where you can find most of the cool open source projects (such as Apache Cordova), including access to the latest patches, builds, and sources. You can easily build your project for multiple platforms using PhoneGap's free online build service from a public GitHub repository.