Debugging cordova-based code on mobile

I think I recall at one point in my app development that I could see console.log() output in my Xcode output, but I don’t see it anymore. My question is, what are people using to debug output via Xcode? Is there a trick to getting the console.log() in the Xcode output?

A painful hack is to create a debug helper and actually output to the screen. I’m doing mobile development revolving around accessing native camera, and it is super painful. I saw that there was a cordova-focused Phonegap plugin for this, but it did not seem like a good fit for meteor.

1 Like

There are two ways to get console output from a Cordova app to show up:

  • Install cordova-plugin-console to get console.log() to call into NSLog() (which shows up in the Xcode console output).
  • Use Safari remote debugging to connect to the web view in your Cordova app so you can use the full capabilities of the Safari Web Inspector.

There’s a third way - use Android. :smile: (To be fair, OP did say Xcode…)

Thanks! The Safari web inspector works pretty well, I just miss the startup since I can’t seem to attach to my app until it is booted, but otherwise it works well.

The trick there is to use window.location.reload() to trigger a reload so you can also observe startup.

So… no debugger? As in, set a breakpoint?

I’m not sure what you mean, but you could definitely use the debugger and set breakpoints. The original question was about console output however.