PhoneGap now also known as Apache Cordova, is a powerful tool for mobile development which allows you to develop in HTML/JS markup and quickly generate out various mobile compatible apps. This prevents your developers from having to learn and understand multiple platform specific languages and instead use the PhoneGap framework which is based in HTML to create the app and then generate it into any one of the following platforms:
- Windows Phone
- Firefox OS
- Amazon Fire OS
With time saved on learning development languages for the above platforms your team can focus on the features of your app.
- Download and install node.js, This will be used to install the Cordova/PhoneGap framework.
- Download and install a Git Client, This is used by the Cordova/PhoneGap framework when creating projects.
- Open command prompt and verify that both of the above systems have been installed by running npm and git.
- Install the Cordova/PhoneGap system by running the following command in your command prompt (Note: this may take a few minutes)
C:\>npm install -g cordova
Verify your installation of Cordova/PhoneGap by running cordova in command prompt. This should display a list of the available Cordova commands.
- Create a directory which will contain your PhoneGap/Cordova project code.
- Open the created directory in command line and create a project with the command cordova create < sitename >
C:\>rootdir\cordova create FirstSite
This will create a project in the root folder with the specified site-name. This project will contain:
- "hooks" directory- Contains special scripts that can be used to customize Cordova commands.
- "platforms" directory- This contains the app specific projects that you will include below.
- "plugins" directory- Contains add-on code for interfacing with native features. You can create your own custom interface or use one of pre-compiled plugins.
- "www" directory- Contains the PhoneGap/Cordova structure and some standard js and css files.
- config.xml file- This file contains meta data for controlling common features of your apps like the app title, description and author.
Add platforms to the project with the cordova platform add
command. Note: adding platforms requires that the relevant dependencies are installed in your system for example adding android requires that you have installed the Android SDK. Available platforms for a windows environment are:
And for Mac:
C:\>rootdir\cordova platform add android
You can now get a list of the added platforms by running the following command:
C:\>rootdir\cordova platform ls
You can remove a specific platform from the list with the following command:
C:\>rootdir\cordova platform remove android
- Once you have added in the desired platforms build the platform specific apps by running the following command:
Note: Building platforms requires that the relevant dependencies are installed in your system for example building android requires that you have installed the Android SDK
- You can use these built projects found in the "platforms" directory in platform specific IDEs or emulate the projects directly with the following command:
C:\>rootdir\cordova emulate android
At this point you have a basic PhoneGap project configured and your desired platforms added and you can get started with adding or building out additional features and content in the "www" directory and run the command in step 7 above to create the platform specific projects. You can find detailed instructions on setting up additional features and implementing PhoneGap on the PhoneGap site.