iOS Dev Nugget 277 REPL in LLDB


Need to run a code review on your codebase? Hire me

Did you know that LLDB includes an REPL?

Set a breakpoint in your Xcode project, say the method that gets run when you hit a button. In the debugger proompt, type repl. i.e.:

(lldb) repl

Then paste this in:

let v = UIView()
v.frame = CGRect(x: 20, y: 20, width: 200, height: 20)
v.backgroundColor = .red
let window =[0]

Hit enter.

You should see that the new red view appears immediately upon CATransaction.flush() while you are still in the debugger. It is important that you are not breaking in application(_:, didFinishLaunchingWithOptions:) for flush() to "load" your changes immediately.

Type : and hit enter to exit the REPL.

Your feedback is valuable: Do you want more nuggets like this?   Yes   or   No



Like this and want such iOS dev nuggets to be emailed to you, weekly?

Sign Me Up! or follow @iosdevnuggets on Twitter


View archives of past issues