How can I properly debug iOS on a simulator?

Hi,

I’m currently trying to get the regular Angular $log-output to show up somewhere when testing on the iOS simulator.
I know I can use the Safari debugging tools, but this won’t log anything before I actually attach the debugger in Safari, i.e. every piece of code that runs before I can attach it can’t be debugged.

Can anyone help me out here?

Well, the XCode console will also show you your console.log output, but it won’t show you ALL the other errors in your javascript or with objects & plugins.

I find the WebInspector to be the best for finding obscure scripting errors that can cause problems in my app. One thing I do is:

  1. Run up the app on the simulator or on your actual device.

  2. Start up the WebInspector debugger window in Safari

  3. Execute the following command in the WebInspector console:

    window.location.reload()

This will force your app to restart in the simulator or device, then you can get a full debugging trail - even those calls made before your app views are rendered. So effectively, you can debug your app from initial startup, that you can’t normally do with WebInspector.

8 Likes

You can always run it from the command line using the live-reload and console flag.

$ ionic emulate ios -lc

This will print the console output right to your terminal

8 Likes

My personal experience is that it’s always the easiest way to debug it with chrome. Start a local webserver and run our application with chrome. The debugger is the best one I know. For all other things (e.g. if you debug push notification things) use xcode.

1 Like

Seconded.

My name is Commander Shepard and I approve this message.

Hi Janson,

I’m quite new to the whole mac/xcode thing. I have inserted several debuggers at my js in xcode, but when I emulate the app in the emulator, the xcode debugger does not stop. Do you know how to debug the ionic js in xcode?

1 Like

HI I have build on c9 an app that gets data via rest api from wordpress. That app works in the browser but when I upload that app to the ionic view no data is loaded same when I run $ ionic emulate ios but when I use $ ionic emulate ios -lc as mharington suggested my app works in ios emulator. What is going on ?

Will my app work on real device as an independent app is there any way to test on real device as an independent app before i release that to itunes.

But some of the features can’t be tested in browser.

Agreed, everytime I try to emulate my app I get “http://requirejs.org/docs/errors.html#scripterror, http://192.168.1.112:8100/lib/requirejs/require.min.js, Line: 1”.

As I use requirejs to build-up my app, even taking it out the ngCordova don’t bootstrap.

you can checkout my answer here, hope this help: http://stackoverflow.com/questions/25689270/debug-ionic-app-on-ios/39652044#39652044

1 Like