Line Logging in Objective-C

Shaun, Feb 25

A helpful debugging tool when you run into an issue is to throw an output after each line of code (or using breakpoints, I prefer line outputs).

It can get a bit messy, so I usually throw the following code in my PCH file in each Xcode project:


Now when I run into an issue in a method crashing, I can do this:


Which will then output the following:


The format is the method name and the line number.

Updated: An earlier version of this post used "startLineLogs(@"method name")" thanks to tips from @rob_rix and @iphonedevmag I've updated logLine to use _cmd instead, which made startLineLogs() unneeded. Thanks guys!

blog comments powered by Disqus