Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find which line error occurs in Xcode? [closed]

Tags:

xcode

ios

swift

I get an error "fatal error: unexpectedly found nil while unwrapping an Optional value" while running my app and I do not know where in the app the error has occurred.

I have two view controllers, and the error for sure doesn't occur in the first view controller because the view of the second controller appears and I also tested with break points in view will appear in the second view controller and everything works fine.

But now I do not know where to put breakpoints in the second view controller. Up to viewDidLoad and viewWillAppear everything works fine, but at the didRecievememoryWarning method the error comes back up again.

Do I have to place break points all over the file and find out which line is causing the error, or is there a quicker way to find out which is the exact line that is causing the error.

like image 721
Harshil.Chokshi Avatar asked Feb 11 '16 18:02

Harshil.Chokshi


People also ask

How do I see errors in Xcode?

cmd+7. click on the top-most "Build $APP" section. locate the warning or error. click the buttons on the right to see the full details of the step you are interested in.

How do you find a line error?

To find out where the error occurs, you could "open the call stack (Debug > Window > Call Stack) to see what functions are causing the problem. You can double click any line in the call stack to jump to the code and look at variable values from that method in the debugger.

How do I fix Xcode errors?

Conversation. Xcode tip #5: If you have a Swift file with many errors, you can use Xcode's fix-its to try to correct them one by one. But a faster way is to go to the Editor menu and choose Fix All Issues to apply fix-its all at once. (Make sure and double-check which changes were made!)

How do I print a stack trace in Swift?

In Objective-C, you can print the call stack by doing the following: NSLog(@"%@", [NSThread callStackSymbols]);


1 Answers

That crash should show up in the debug navigator. It shows you the instruction that caused the crash.

enter image description here

like image 93
Chris Slowik Avatar answered Sep 28 '22 02:09

Chris Slowik