Reputation: 997
I just started playing around with Phonegap tonight, and I love it! But I'm having a few issues.
On their website, there's two different installation procedures: one is listed here: http://phonegap.com/install/, and the other is listed here: http://docs.phonegap.com/en/3.0.0/guide_cli_index.md.html#The%20Command-line%20Interface
There is also a difference in many of the examples I see, with some referencing phonegap.js in the HTML file, and others using cordova.js in the HTML files. What is the difference between these two installations, and these two JS files?
Next, whenever I try to get any of the device properties, nothing happens (I'm assuming an error is being thrown, because no other code will execute). For example, if I do "document.write(device.name)" I get nothing, but if I do "document.write('test')" it works fine
Finally, for the "phonegap" version, I'm running phonegap build ios, then I go into xcode where the project is open, and I click Run. Whenever I do console.log, I was hoping that I would see the output in the xcode debug window, but that's not happening. Is there any way to send console (and error) messages to the xcode console?
Thanks!
Upvotes: 1
Views: 765
Reputation: 865
Those cli installation differences are best seen by their commands https://github.com/mwbrooks/phonegap-cli and https://github.com/apache/cordova-cli
PhoneGap is a distribution of Apache Cordova. You can think of Apache Cordova as the engine that powers PhoneGap, similar to how WebKit is the engine that powers Chrome or Safari. (Browser geeks, please allow me the affordance of this analogy and I’ll buy you a beer later.)
Currently there isn't much of a difference, but as time goes on there will probably more adobe tools added in. source
When you try to get the device properties make sure you are following these tips or here
When you use console.log in Xcode they are logged to the Xcode debug console. Make sure you are calling console.log after the deviceready event is fired. In order to see the logs with tools other than Xcode check out weinre , You could attach web inspector to safari on you mobile device or other tools like it. Phonegap also has these tips for debugging and seeing logs here.
Upvotes: 1
Reputation: 1235
I think what you may need to do (if you haven't already) is to install the necessary plugins first. To access the device API, install this plugin:
$ phonegap plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-device.git
To enable the debug console, install this plugin:
$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-console.git
If you're working on a cordova project, I think you can just replace "phonegap" with "cordova" in the code above.
I ran into similar issues with console.log() not working in xcode, and once I installed the plugin... it started working for me. One tip: considering quitting out of xcode before you install these plugins. Then open it back up and give it a whirl. Not sure if this matters or not, but I did this to play things safe.
Upvotes: 2