First, installing:
To install PhoneGap you should first install the Node.js framework (npm) since that will enable you to install Cordova (the Apache project that enables embedding Web applications within native applications of mobile platforms such as Android, iOS etc.)
So, to install Node.js you just type
For OS/X, I suggest installing the homebrew package manager from here and then:
brew install npm
For Linux (or rather Ubuntu 12.04) the obvious path was to run
sudo apt-get install npm
however, the version of npm installed caused problems further down the road (for example getting an ECONNREFUSED when attempting to add a plugin). My advice for Ubuntu 12.04 then is to try one of two things:
1. try getting the latest version of npm by:
sudo apt-get install --yes build-essential curl git #install latest node sudo apt-get install --yes python-software-properties python g++ make sudo add-apt-repository --yes ppa:chris-lea/node.js sudo apt-get update sudo apt-get install --yes nodejs node -v
The above was taken from here.
2. use the following script (taken from here:
# Save as ~/npm_install.sh, chmod u+x and run it. It will take a long while to complete... # The install script # Adapted from https://gist.github.com/579814 echo ' ' >> ~/.bashrc echo '# Added by install script for node.js and npm' >> ~/.bashrc echo 'export PATH=$HOME/local/bin:$PATH' >> ~/.bashrc echo 'export NODE_PATH=$HOME/local/lib/node_modules' >> ~/.bashrc . ~/.bashrc mkdir -p ~/local mkdir -p ~/Downloads/node-latest-install cd ~/Downloads/node-latest-install curl http://nodejs.org/dist/node-latest.tar.gz | tar xz --strip-components=1 ./configure --prefix=~/local # if SSL support is not required, use --without-ssl make install
Ok, now that we have npm installed, lets use it to install Cordova. Cordova is the engine that powers PhoneGap.
So we install Cordova:
On both Ubuntu and OS/X it’s just a matter of:
sudo npm install -g cordova
Now, having Cordova installed, you’ll need to download the Android SDK to embed Web applications as Android applications with Cordova, and you’ll need to have Xcode to embed your Web applications in iOS, but after that, you can start using Cordova command line just installed to compile your web application to a mobile phone application.
After this you’ll have access to cordova via the command line.
Using cordova to build and run your apps will be discussed in the next posts.