Skip to content Skip to sidebar Skip to footer

How To See Phonegap Javascript Log Messages On Xcode Console

I am trying to develop a basic hello world application with phonegap on Xcode. But i can not see the log messages on Xcode console. I have tried console.log and debug.log but they

Solution 1:

In Phonegap 3.0 you have to add a plugin for console.log to work in the xcode console.

$ phonegap local plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-console.git

More info: http://docs.phonegap.com/en/edge/guide_cli_index.md.html#The%20Command-line%20Interface

Solution 2:

  1. On your real iDevice or in iOS simulator go to Settings > Safari > Advanced and turn on Web Inspector.
  2. Desktop Safari: Safari > Preferences > Advanced and select the Show develop menu in menu bar checkbox.
  3. Now that you have either iOS Simulator open or your iDevice connected to your mac start using web inspector on your website: On your mac, open Safari and go to Develop

Solution 3:

Phonegap has a pretty good blog post about this here.

One of the things they mention includes JSLint which I personally use a decent amount. You just post your JS code there and it'll scan for errors and good styling. I also suggest trying to put t the code in a simple html file and run it on the browser. Anything that might seem phone-related, just get rid of it. Its nice to sandbox your javascript on the browser side and then use things like Firebug or Chrome's debugger. (Also I'm sure console.log() will work there :D)

I've also seen a lot of people mention, including in the blog post, about Weinre so that is something worth checking out.

Other relevant questions that might help:

Phonegap - Javascript debugging in Xcode

iOS PhoneGap debug Workflow

How to see the javascript errors of PhoneGap app in Xcode?

Hope this helps.

EDIT: Found this recently: Debugging in Phonegap

Solution 4:

console.log("msg here: "+var); should work. It will come out as ...[INFO] msg here: hi! (after the date, time, app, etc.).

To view the messages go to View > Debug Area > Activate Console (or shift+cmd+C)

Solution 5:

As @NickBreen said, you must add the right plugin, but we also needed to wait for the deviceready event to fire before the console displayed log statements.

Post a Comment for "How To See Phonegap Javascript Log Messages On Xcode Console"