This document describes how to install Apache Cordova and SDKs for iOS and Android on an OS X machine.
Follow these steps to install Cordova:
Install Node.js. Cordova runs on the Node.js platform, which needs to be installed as the first step. Download installer from: http://nodejs.org
Go ahead an run the downloaded installation file.
To test the installation, open a terminal window (make sure you open a new terminal window to get the settings made by the Node.js installation), and type:
node --versionIf the version number is displayed, Node.js is installed and working!
Install Git. Git is a version control system, which is used by Cordova behind-the-scenes. Download the installer from: http://git-scm.com.
Install Cordova. Cordova is installed using the Node Package Manager (npm). Type the following in the terminal window to install:
sudo npm install -g cordova
Test the Cordova install by typing:
cordova --versionIf you see the version number, you have successfully installed Apache Cordova!
If you wish to develop iOS apps, go ahead and install Xcode, which is Apple's development tool for iOS app development:
To access iOS development resources, you need to sign up for an Apple account if you have not already done that.
To deploy apps on devices (iPhone and iPad) and to publish apps on the AppStore, you should join Apple's iOS Developer Program. This costs 99 USD per year.
Install Xcode from: https://developer.apple.com/xcode/downloads
When the install is complete, launch Xcode and enable the command line tools for Xcode (these are used by Cordova).
From the Xcode menu, select Preferences...
Select the Downloads tab.
Under Components, locate Command Line Tools and click the download icon.
If you get stuck, try out the Cordova documentation for iOS.
Xcode is now ready to be used with Cordova. The way this works that that you create and build a Cordova project, the build process generates an Xcode project, that you just double-click to open. When your project is open in Xcode, you can run it in the iOS simulator or deploy the app to a device. Follow the instructions in the Cordova Guide to try this!
To develop Android apps, you need to install Java, the Ant build tool, and the Android SDK.
To use the Android SDK the Java SDK needs to be installed (minimum version 1.6). How to install:
To check if Java is already installed, type this in a terminal window:
javac -versionIf you see a version number at or above 1.6 you should be good to go.
Start by checking if you have Ant installed by opening a terminal window and run:
ant -versionIf you see a version number, Ant is already installed.
Next, check if you have Homebrew installed by typing:
brew --versionIf you see a version number, Homebrew in installed.
If you have Homebrew installed, but not Ant, install Ant from a terminal window using these commands:
brew update brew install ant
If neither Homebrew nor Ant is installed, install both of them with the following commands:
ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)" brew install ant
Now test the install with:
Download the Android Developer Tools (Eclipse ADT) from developer.android.com/sdk. The install is a zip-file, which you can unpack to a location of your choice. Make a note of there you install the SDK files, as you will have to add these to the system path.
Add the path to the folder where you unzipped the Android SDK tools to the files .bash_profile and .bashrc (these files are located in your home directory). This is needed for Cordova to find the Android build tools.
Edit .bashrc in nano (or any editor you prefer) by typing the following in a terminal window (the cd command takes you to your home directory).
cd nano .bashrc
In the nano editor, add the following line, with "/Users/username/android" substituted by the actual location of the Android SDK (note that there are two paths in one line, separated by a colon):
Save and exit by typing CTRL+O (the letter key O) and CTRL+X.
Next, check that .bashrc is loaded by .bash_profile (.bash_profile is loaded when you open a terminal window, and we want the path set for terminal windows). Open the file .bash_profile in nano:
If not present already, add the following lines to .bash_profile:
if [ -f ~/.bashrc ]; then source ~/.bashrc fi
Now test the install. Close any open terminal windows, open a new terminal window and type:
adb versionThis should display the version of the Android Debug Bridge.
As the final step, you need to get the specific Android SDK version used by Cordova. This is done by running the Android SDK Manager by typing the command:
androidThis launches a window where you can select to install specific Android SDKs.
First time you launch the Android SDK Manager there will be preset selections. It is recommended to leave these untouched. Also select the entry "Android 4.4.2 (API 19)". This is the version used by the current Cordova 3.5 version. Note that the Android SDK required by Cordova will change in the future, as new versions of Cordova and Android are released. When this happens, open the Android SDK Manager again, and install the required API version(s).
Next step is to create and build a Cordova project. Go to the Cordova Guide to learn more.