iOS app crash on launch using XCode debugger, runs fine without debugger
Asked Answered
S

1

5

When running the app on a device (iphone), it crashes at startup without any error messages. But if the device is not connected to xcode (not in debug mode), just open up the app, it runs fine.

Same code runs perfect on simulator.

Never seen this before, I guess something went wrong in code signing setting or LLDB debugger, but I can't work it out.

I just cannot run on a real device to debug, any idea? It stop here:

int main(int argc, char * argv[]) {
    @autoreleasepool {
        // stop here:
        return UIApplicationMain(argc, argv, nil,  NSStringFromClass([AppDelegate class])); 
    }
}

==== 2015/6/19 Edited ====

Thanks to Jim Ingham give a clear explanation. Before, I set Xcode to catch all exceptions like this:

enter image description here

This is convenient when development. However this breakpoint exception include both C++ and Obj-C type. By exclude catching the C++ breakpoints, we can solve this problem:

enter image description here

Shroff answered 15/6, 2015 at 3:9 Comment(11)
When app "crash", it probably stops at some line of code and don't go further... Try clicking triangle as you would like to go further in debug mode.Maxantia
Thanks for reply. I've added the breakpoint for all exceptions. But it didn't tell anything.Shroff
Did you try to go forward in debug mode? As you posted in your question, when application stops after autoreleaspool line try to click triangle to go forward.Maxantia
The farest the program can go was the very begining line I indicated above.Shroff
I didn't put a break point there, it just stops there.Shroff
I know but I steal need to know if you try to push triangle... I have some cases where when I tested on real device program stops at same spot (without breakpoints, like crash), but work when I click on go further button.Maxantia
Oh my god, you're right! It works when I push forward button in debugger. That's wired since it stop at somewhere without a breakpoint. Anyway, thank you so much!Shroff
When your app stops in the debugger, it will show the stop reason in the little tag thats part of the current PC marker, it will be on the RHS of the editor window. You can also see the same text if you go to the console and do: (lldb) thread list in the reason field of that output. What was the stop reason in the situation you are describing?Gwennie
@JimIngham Thanks for that hint. The reason is due to "breakpoint 1.4". And breakpoint list shows the breakpoint 1.4 is 1.4: where = libc++abi.dylib`__cxa_throw, address = 0x00000001143f9519, resolved, hit count = 1 , I don't understand why this breakpoint is automatically generated.Shroff
That is the C++ Exception Throw breakpoint. That breakpoint is not set by default. Check the Breakpoints Navigator for this project and see if you maybe set it at some point and forgot about that. Note that if you set an "Exception Breakpoint" by default it sets it for C++ & ObjC. If you are only interested in catching ObjC exceptions, just switch it to ObjC. Also, this isn't a crash, just a breakpoint, so you can just hit continue and the app should go on its way correctly.Gwennie
I had same problem to. I can confirm this is answerBerrios
M
7

Sometimes when you debug with real device, new version of Xcode stops your prices at beginning like described in question :

int main(int argc, char * argv[]) {
    @autoreleasepool {
        // stop here:
        return UIApplicationMain(argc, argv, nil,  NSStringFromClass([AppDelegate class])); 
    }
}

but this is not real crash (it is just some security staff - I guess ), and all you need to do is click on triangle button for go further in debug mode.

Yes I know there was no breakpoint, but do it anyway.

Maxantia answered 15/6, 2015 at 6:38 Comment(1)
Thanks for this. And thanks Xcode - that's 45 minutes of my life I'll never get back!Arrant

© 2022 - 2024 — McMap. All rights reserved.