Phonegap Help: device properties, cordova v phonegap, xcode debugging

I just started playing with Phonegap tonight and I love it! But I have a few problems.

There are two different installation procedures on their website: 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

In the many examples that I see, there is also a difference with some links to 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?

Further, whenever I try to get any properties of the device, nothing happens (I assume that the error occurs because other code will not be executed). For example, if I do "document.write (device.name)" I get nothing, but if so, "document.write (" test "), it works fine

Finally, for the "phonegap" version, I run javascript to build phonegap, then I go to xcode where the project is open, and I click "Run." Whenever I do console.log, I was hoping to see the output in the xcode debug window, but that would not happen. Is there a way to send console messages (and errors) to the xcode console?

Thanks!

+1
source share
2 answers

I think that you may need (if you have not done so already) - first install the necessary plugins. 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 are working on a cordova project, I think you can just replace "phonegap" with "cordova" in the code above.

I ran into similar problems when console.log () did not work in xcode, and as soon as I installed the plugin ... it started working for me. One tip: consider abandoning xcode before installing these plugins. Then open it and give it a whirlwind. Not sure if it matters or not, but I did it to play it safe.

+2
source

These differences in installing cli are best seen by their commands https://github.com/mwbrooks/phonegap-cli and https://github.com/apache/cordova-cli

PhoneGap is the Apache Cordova distribution. You can think of Apache Cordoba as an engine that supports PhoneGap, much like a WebKit engine that includes Chrome or Safari. (Browser geeks, please allow me to admit this analogy, and I will buy you a beer later.)

There is not much difference at the moment, but over time, additional adobe tools will be added. source

When trying to get device properties make sure you follow these tips or here

When you use console.log in Xcode, they log into the Xcode debug console. Make sure you call console.log after the deviceready event is fired. To view logs with tools other than Xcode, check out weinre , you can attach a web inspector to safari on your mobile device or other similar tools. Phonegap also has these tips for debugging and viewing logs here .

+1
source

Source: https://habr.com/ru/post/1499416/


All Articles