Installing Cordova and SDKs on OS X

This document describes how to install Apache Cordova and SDKs for iOS and Android on an OS X machine.

Install Cordova

Follow these steps to install Cordova:

  1. 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

  2. Go ahead an run the downloaded installation file.

  3. 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 --version
    If the version number is displayed, Node.js is installed and working!

  4. Install Git. Git is a version control system, which is used by Cordova behind-the-scenes. Download the installer from: http://git-scm.com.

  5. 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

  6. Test the Cordova install by typing:

    cordova --version
    If you see the version number, you have successfully installed Apache Cordova!

Install Xcode for iOS development

If you wish to develop iOS apps, go ahead and install Xcode, which is Apple's development tool for iOS app development:

  1. To access iOS development resources, you need to sign up for an Apple account if you have not already done that.

  2. 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.

  3. Install Xcode from: https://developer.apple.com/xcode/downloads

  4. 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.

  5. 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!

Install the Android SDK

To develop Android apps, you need to install Java, the Ant build tool, and the Android SDK.

Install Java

To use the Android SDK the Java SDK needs to be installed (minimum version 1.6). How to install:

  1. To check if Java is already installed, type this in a terminal window:

    javac -version
    If you see a version number at or above 1.6 you should be good to go.

  2. If Java is not installed, get the Java for OS X installer from Apple's download page. Direct link: support.apple.com/kb/DL1572.

Install Ant

Apache Ant is a build system for Java, which is used by Cordova and the Android SDK. Use Homebrew to install Ant, using the following steps:

  1. Start by checking if you have Ant installed by opening a terminal window and run:

    ant -version
    If you see a version number, Ant is already installed.

  2. Next, check if you have Homebrew installed by typing:

    brew --version
    If you see a version number, Homebrew in installed.

  3. If you have Homebrew installed, but not Ant, install Ant from a terminal window using these commands:

    brew update
    brew install ant
  4. 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
  5. Now test the install with:

    ant -version

Install Android Developer Tools (ADT)

  1. 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.

  2. 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.

  3. 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

  4. 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):

    export PATH=/Users/username/android/sdk/platform-tools:/Users/username/android/sdk/tools:$PATH

    Save and exit by typing CTRL+O (the letter key O) and CTRL+X.

  5. 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:

    nano .bash_profile

  6. If not present already, add the following lines to .bash_profile:

    if [ -f ~/.bashrc ]; then
       source ~/.bashrc
    fi

  7. Now test the install. Close any open terminal windows, open a new terminal window and type:

    adb version
    This should display the version of the Android Debug Bridge.

  8. 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:

    android
    This launches a window where you can select to install specific Android SDKs.

  9. 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).

If you get stuck, consult the Cordova documentation for Android. You are also welcome to ask for help at the Evothings Forum.

The fun begins

Next step is to create and build a Cordova project. Go to the Cordova Guide to learn more.

Use Evothings Studio for Cordova app development

Evothings Studio makes it easy to develop Cordova apps. Check out how to use your Cordova project with the fast Evothings workflow.

It is easy and fun to get started with Evothings Studio. Download now and be up and running in 5 minutes!