Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I debug js code using Cordova and ios simulator?

I am using xcode 4.5.2 and PhoneGap (Cordova) to develop an iphone app.

Looking at the Log Navigator in xcode does not show me any of the js console.logs.

What must I do to be able to see these log outputs?

like image 797
Harry Avatar asked Jan 24 '13 16:01

Harry


People also ask

How do I debug a Cordova app on Safari?

To enable debugging on iOS, In the iOS device, go to Settings → Safari → Advanced → Enable 'Web Inspector' From the Mac, Safari → Preferences → Advanced → Enable 'Show Develop menu in menu bar' Once this is done, start the Cordova application and connect your iOS device with USB cable.

How do I test my Cordova app on iOS?

You can test many of the Cordova features using the iOS emulator installed with the iOS SDK and Xcode, but you need an actual device to fully test all of the app's device features before submitting to the App Store. The device must have at least iOS 6. x installed, the minimum iOS version supported as of Cordova 3.0.


2 Answers

This may be a little late but its quite simple.

So in Safari, Go preferences -> advanced -> Show Develop menu in menu bar. Once you've that, build and run in xcode and then in safari go Develop -> iPhone Simulator -> Your App Name.

It works pretty well but I can't find a way to make it persist as such, so you need to repeat this after every run seemingly, which is a pain. If I find a way I'll post here.

Additional:

As Harry points out below in the comments, you can then run location.reload in the safari console to reload the Cordova app and see all the log messages from the boot of the application

like image 162
Niall Paterson Avatar answered Sep 19 '22 08:09

Niall Paterson


I found a little help to open the console for ios simulator

http://blog.persistent.info/2014/06/adding-keyboard-shortcuts-for.html

like image 34
Lil'Monster 987 Avatar answered Sep 22 '22 08:09

Lil'Monster 987