Where do I get a readable stack trace in Xcode? - ios

The following is the exception I get from iOS. It looks ridiculously unreadable (my brain is screaming wtf ten thousand miles per second). So this can’t be right. When I am developing for android, and I get an exception, the stack trace is completely readable, no magic such as 0x187d27bc8. So am I looking at the wrong window? Where in Xcode to I go to find a readable version of my stack trace? In eclipse there is a line number I can click on to get to the exact line that caused the error.
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '* -[__NSPlaceholderArray initWithObjects:count:]: attempt to insert nil object from objects[0]'
*** First throw call stack:
(0x1835a6084 0x193b840e4 0x18348f300 0x18349b5b8 0x100185c94 0x100185af4 0x10009f7b4 0x10009ede4 0x10009ec9c 0x10006c5a0 0x1882f32b8 0x10006c358 0x187d5d2f4 0x187d4644c 0x187d5cc90 0x187d1c724 0x187d567b8 0x187d55e58 0x187d29660 0x187fc7d6c 0x187d27bc8 0x18355e324 0x18355d5c8 0x18355b678 0x183489664 0x18c5cb5a4 0x187d8e984 0x100139854 0x1941f2a08)
libc++abi.dylib: terminating with uncaught exception of type NSException

In your menu bar go to: Debug -> BreakPoints -> Create Exception BreakPoints. And that should do it. So the next time you run the code, it will stop at the line that caused the exception. And then to the left, you should see the stack trace.

Related

iOS app termination due to uncaught error

This is the exception and in my ignorance of using the tools in the IDE I have a very basic question. How do I go to the line of code that causes the issue? I have located where the issue is, but rather than NSLogging a message in the didload and didAppear events, then stepping through the code until is breaks seems like a long way to figure this out. I am assuming that the [5970:1623718] is a clue, but to what?
2017-10-04 08:22:47.798 Auto Mileage - Universal[5970:1623718] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 4 beyond bounds [0 .. 3]'
*** First throw call stack:
(0x2580f91b 0x24faae17 0x2572172b 0xd89e3 0xd9e57 0x2a0d1465 0x2a0d15a5 0x2a0c0b51 0x2a0d5d1b 0x29e7523b 0x29d86a73 0x27e1ebcd 0x27e1a375 0x27e1a209 0x27e196d1 0x27e193a5 0x29d7db79 0x257d16c9 0x257cf9cd 0x257cfdff 0x2571f229 0x2571f015 0x26d0fac9 0x29df3189 0xe9159 0x253c7873)
libc++abi.dylib: terminating with uncaught exception of type NSException
You can add an "Exception Breakpoint".
Like in the picture, select "Show the Breakpoint navigator" (the blue icon on the top of the navigator), then click on the plus icon on the bottom and click on "Add Exception Breakpoint".

Detect array with issue (Debug mode)

My app is crushing when i'm calling a few methods
I can see the error message and I understand what it say but I don't know how to detect the array with the problem by the message.
I have lots of arrays in the project.
how can I know from where the problem come from?
this is the message:
2014-12-16 15:07:01.830 myApp[2776:1237923] *** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(0x2a3eae3f 0x37a98c8b 0x2a2ffc49 0x114c07 0x2d8e515d 0x2d8e3835 0x2d8df47d 0x2d885b37 0x2d2adccd 0x2d2a96b5 0x2d2a953d 0x2d2a8f21 0x2d2a8d25 0x2d2a2bfd 0x2a3b15cd 0x2a3aec8b 0x2a3af093 0x2a2fd621 0x2a2fd433 0x316ab0a9 0x2d8e7809 0x12fee5 0x38018aaf)
libc++abi.dylib: terminating with uncaught exception of type NSException
To handle All exceptions, From Xcode click on Show the Breakpoint Navigator
Click + button at bottom side and from pop up click on Add Exception Breakpoint.
This will add exception break points for application, try to run again and execution will stop if any runtime exception raised.
If this will not help, enable zombie environment for project, check out from this thread -
How to set exception breakpoint from Xcode
Enable Zombie Object in Xcode for better error tracing.
To enable
Press Command+Option+R
Under Diagnostic tab-> Memory Management
Check "Enable Zombie Object"
Hope this Helps

iPhone Project crash on start

I am trying to run my application and suddenly i get this error:
2014-11-05 12:12:54.972 [238:9512] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: ''
*** First throw call stack:
(0x235a7c1f 0x30dafc8b 0x235a7b65 0x299b61 0x299adf 0x322ec7 0x13b50d 0x242b6d6f 0x2356e377 0x2356d787 0x2356bded 0x234ba211 0x234ba023 0x2a86d0a9 0x26ac61d1 0x102bff 0x102b88)
libc++abi.dylib: terminating with uncaught exception of type NSException
It's on the start of the application,
i get this error without changing any code in my project, any idea what can cause this?
To resolve the NSException crashes, you have to remove all the warnings of .xib/.storyboard files. Cross check the IBOutlets warnings and you can see a cross (X) icon related to the yellow warnings to remove it.

How can I find out the name of an array causing a crash by address on iOS?

So I keep getting this crash and break in my code, but I can't figure out exactly where it's coming from. Xcode doesn't break on the line that is relevant to this, and I looked through all of the thread stacks and none of them show the break. Here is what I am getting:
*** Terminating app due to uncaught exception 'NSGenericException', reason: '***
Collection <CALayerArray: 0x17746b10> was mutated while being enumerated.'
My question is, how so I find out where this array is? Is there some way to look it up in the Xcode console by address to point me to what exactly is happening here? I can't find where I would be mutating some array just by eyeballing my code.
Add exception breakpoint and check the location for crash.
1) Go to the breakpoint navigator.
2) At the bottom left corner click on the ADD
3) Now select "Add Exception Bearkpoint" in that.
4) Make sure "Exception Breakpoint" is enabled.
5) Right click on breakpoint and Change the exception type to Objective-C.
Now run you app and debug the crash area.

Debugging uncaught exception in Xcode

I'm trying to get better at using Xcode. I have the AllExceptions break point turned on. When my app crashes, I see this:
*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]'
*** First throw call stack:
(0xbb8052 0x209cd0a 0xba4db8 0x2255f2 0xc2439 0x12a5e0f 0x12a6589 0x146bfb1 0x147617c 0x12938e1 0x1290602 0x129b211 0x129b23f 0xc16a6 0x138a4c 0x138852 0x14d0e39 0x14d0143 0x14d13cf 0x14d3a31 0x14d398c 0x14cc3e7 0x1234812 0x1234ba2 0x121b384 0x120eaa9 0x28d3fa9 0xb8c1c5 0xaf1022 0xaef90a 0xaeedb4 0xaeeccb 0x28d2879 0x28d293e 0x120ca9b 0x265c 0x25c5)
terminate called throwing an exception(lldb)
On the LHS, when I look at the different threads, I don't see anything that really makes sense. I see some CFRunLoop stuff, but I don't see any "normal" method names like UITableView delegate/datasource methods or my own methods. I was wondering if there was a more informative stack trace available instead of the hex stuff when my app crashes. I know I can set breakpoints at each place I'm accessing the array I think I have a problem with since I'm basically just trying to have an accordion-like tableview with our specific datasource, but I was wondering if there was a faster way by looking at something useful in Xcode. Thanks!
In Xcode,
go to Breakpoint navigator on the left pane.
Click '+' at the bottom.
Choose 'Add exception Breakpoint...'
Let the default selections there and click 'Done'.
Rerun the app and see if execution stops at the line which causing this exception.
The easiest way to handle the exceptions in XCode during development is to add the exception break points.
You can do that as following.
From left menu select Exceptions navigator
Add the exception break point from bottom left button.
Add break point for all the exceptions
Run the app.
In most of the cases XCode will stop the execution on exception and point at the line that caused the exception.

Resources