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 = UIApplication.shared.windows[0]
window.rootViewController?.view.addSubview(v)
CATransaction.flush()
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
.
.