Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to find source of print() or NSLog() console output in Xcode

Tags:

xcode

I'm not sure if this is possible. Here is an example situation:

Something is printing to my console and I don't know where it is coming from in the code. I did a quick search using the Finder in Xcode on terms such as 'NSLog' and 'print'. Nothing relevant came up.

Is there any quick way that Xcode has of finding where the source of the output is coming from ?

Kind of like when you right click on a method and you have all the options of exploring different parts of the code associated with that method.

Also: are there other functions that print besides NSLog and print?

Thanks so much!

like image 895
Eric Brotto Avatar asked Aug 06 '10 11:08

Eric Brotto


2 Answers

Try running in the debugger, with breakpoints set on printf, NSLog, etc. When you hit a breakpoint do a backtrace (bt) to see where it's being called from

like image 55
Paul R Avatar answered Oct 16 '22 00:10

Paul R


There's a plugin LinkedLog for that. You replace all NSLogs with LLogs and then will be able to just tap on link in Xcode's console to get to the line caused it to appear.

enter image description here

Didn't try it myself, but definitely will.

like image 41
MANIAK_dobrii Avatar answered Oct 15 '22 22:10

MANIAK_dobrii