Adobe PhoneGap is a development platform which enables the creation of mobile application across a wide range of platforms using standard web technologies/languages. Adobe is heavily pushing the cloud based build and debug version of the tool. Although it works well from Adobe DreamWeaver I have found it no substitute for the Xcode based plugin. For more information regarding PhoneGap itself refer to the website http://phonegap.com.
Unfortunately as Adobe are moving PhoneGap in to the cloud I have found the local build methods to be difficult to follow as a single working set of instructions for the current version (2.9.0) does not appear to exist.
The following is not intended as an exhaustive installation guide rather a set of tips or pointers to which instructions should be followed to install version 2.9.0 on OSX/Xcode and build you first iOS application:-
- Open Xcode, select Xcode from the top left of the screen, select preferences. Change to the Downloads tab and download/install command line tools. Close Xcode.
- Taking instruction from http://phonegap.com/install/ install NodeJS available at http://nodejs.org
- Again taking instruction from http://phonegap.com/install/ install PhoneGap by entering the following command in a terminal window sudo npm install -g phonegap
At this point instructions breakdown as the commands available at http://docs.phonegap.com/en/3.0.0/guide_platforms_ios_index.md.html are incorrect e.g. the command cordova is now phonegap.
- To build your first application environment ready for xcode open a terminal window, navigate to the folder in which your projects will be based and issue the command phonegap create hello com.example.hello “HelloWorld”. This will create a folder named hello and populate it with a folder structure to develop in .
- Next generate the iOS specific environment including the Xcode project by first navigating to the root of the project folder e.g. cd hello once in the project folder issue the command phonegap build iOS. This will prepare the iOS build for the first time and create an Xcode project file which you can load into Xcode.
You are now in pretty good shape, but you will need to manually start the iOS simulator in Xcode when debugging. For every project you wish to start repeat steps 4 to 5.
If you want to automate the starting of the simulator perform the following:-
- Issue the command phonegap run ios in the terminal window. You will notice an error message recommending that you download a plugin from https://github.com/phonegap/ios-sim.
- Open the site https://github.com/phonegap/ios-sim and follow the instructions to install the small ios-sim application which launches the iOS simulator when the command phonegap run ios is given. Again this may not be as easy as it seems unless you have homebrew installed or have used github before. I did the following:-
- from a terminal window changed to the download folder
- enter the command curl -L https://github.com/phonegap/ios-sim/zipball/1.8 -o ios-sim-1.8.zip to download the file
- unzipped the contents of the file with the following command unzip ios-sim-1.8.zip
- changed the terminal path to the extracted folder e.g. cd phonegap-ios-sim-1.8
- install the ios-sim applicaiton using the command sudo rake install prefix=/usr/local/bin
Provided the above steps were successful you can now compile and launch the project by issuing the command phonegap run ios from your project folder.