r/iOSProgramming • • Oct 31 '20

Discussion Efficiently debugging code using Xcode Breakpoint

207 Upvotes

11 comments sorted by

View all comments

13

u/SirensToGo Objective-C / Swift Oct 31 '20

You can also do all of this from the lldb itself:

  1. Set a breakpoint somewhere (br s -n "-[Class func]")

  2. Configure the condition with breakpoint modify -c '<<condition>>' 1

  3. Configure expressions to evaluate/actions to perform when the breakpoint is hit with breakpoint command add <<breakpoint ID>>

Knowing how to use lldb for this is really great because not only can it be faster, but Xcode's graphical debugger breaks ALL THE TIME and gives slow and sometimes inaccurate information. lldb directly is faster and also works well on all sorts of different languages

1

u/etaionshrd Objective-C / Swift Oct 31 '20

Xcode’s graphical debugger uses the LLDB APIs, though…

2

u/SirensToGo Objective-C / Swift Oct 31 '20

It does, just not well. Have you ever hit a breakpoint in a function with a ton of variables? Xcode just freezes for a like ten seconds while it runs a recursive inspection on every single variable, no matter how complex it is.