31

In the past, with the old and good Xcode 3, every time I had a crash, Xcode stopped at the offending line showing the crash. It was good times, nice to debug.

Now with Xcode 4.2, every time the app crashes, it stops at main.m at this line

int retVal = UIApplicationMain(argc, argv, nil, @"AppDelegate");

that gives no clue to what is causing the crash. The problem can be in any class but it will always stop on main.m when it crashes.

is there a way to make it work correctly again?

thanks

note: I have asked this before on SO, but the solution given that time was proved to be not satisfactory and the problem persists.

Duck
  • 34,902
  • 47
  • 248
  • 470

2 Answers2

48

They changed the behavior, follow this tutorial to break on all exceptions

EDIT:(Link might rot, so I will duplicate the info here)

One of the hidden gems in Xcode 4.2 is the “Exception Breakpoint” feature. Once you enable it, your debugging life becomes much easier because whenever an exception is thrown in your app, Xcode will bring up the line of code that caused the exception to occur. This is particularly useful if your call stack window is empty (which I have seen happen sometimes while working on iOS apps). Instead of relying on a brief error message in the Output pane, which doesn’t contain much more than the type of exception and its error message, you get to see exactly where the problem is!

You can add an Exception Breakpoint by opening up the Breakpoint Navigator pane, and clicking on the X button in the bottom left corner:

After clicking the “Add Exception Breakpoint…” menu item, you will see this breakpoint configuration view open up:

Click the Done button and you will the new Exception Breakpoint in your list of breakpoints. If you want to have all of your Xcode workspaces include the Exception Breakpoint, right-click (Ctrl + click) on it and open the “Move Breakpoint To” menu item:

After clicking “User” in the submenu, you will see that the Exception Breakpoint is in the User group of breakpoints. Open up another project and it automatically be included in the list of breakpoints.

Happy debugging!

Keale
  • 3,924
  • 3
  • 29
  • 46
BarrettJ
  • 3,431
  • 2
  • 29
  • 26
  • 14
    Thanks. They must be insane. Whats the point of that change? Make developers' lives miserable? thanks!!!!!!!!!!!!!!!! – Duck Nov 30 '11 at 04:39
  • the bit at the end of the tutorial about moving it to "User" makes it permanent – BarrettJ Nov 30 '11 at 04:45
5

Just try the below steps which worked for me.

  1. Open Preferences, select Behaviors tab.
  2. Select "Run exits unexpectedly" from left column.
  3. Select "Show debugger with current views".

Unfortunately this is reverted back to main.m in the editor again :) Now you need to follow below steps

  1. Open Preferences, select Behaviors tab.
  2. Just go to "run completes"
  3. There find the "Show" line and click the checkbox
  4. On the same line modify target to go to "Current" in the dropdown menu.

This should work

Krishna Kishore
  • 924
  • 8
  • 4
  • 1
    wow. Next release Apple should make it harder to config. Thanks – Duck Nov 30 '11 at 05:04
  • Hahah! They still have **EXACT** the same bugs. It just does not make sense to jump to a file that does not tell you anything. If I uncheck all boxes, I assume (like Apple taught me) that NOTING happens. In stead the happens something. *"If the user does not want to do nothing for this event, jump to a random meaningless file"* Sad. – Julian F. Weinert Jul 21 '15 at 16:50