Xcode ToolsMidOpen-ended

How do you use breakpoints effectively in Xcode?

Explanation & Code

Answer: Breakpoints pause execution so you can inspect state. Xcode has several types beyond simple line breaks.

Types of breakpoints:

Line breakpoint       — pause at a specific line (click gutter)
Conditional breakpoint — pause only when condition is true
Symbolic breakpoint    — pause when any method with a name is called
Exception breakpoint   — pause when any exception is thrown
watchpoint             — pause when a variable's value changes

Tips:

// 1. Conditional breakpoint — right-click → Edit Breakpoint
// Condition: indexPath.row == 5 && indexPath.section == 0

// 2. Action breakpoint — log without stopping execution
// Add action: "po user.name" — logs to console, continues

// 3. Symbolic breakpoint for a framework method
// Symbol: -[UIViewController viewDidAppear:]
// Catches every viewDidAppear in the app

// 4. LLDB in console
po user           // print description of 'user'
p user.name       // print property
expr user.name = "Alice"  // modify value while paused
bt                // backtrace — see call stack

Rate your understanding:

Ready to practice more Xcode Tools?

Test yourself with our interactive quiz mode or browse all curated questions for this topic.