I can never remember how to use LLDB when it comes time, and usually that’s in the most high pressure of moments. Jotting down a few notes on how to debug UI using LLDB. Some really powerful stuff here. See linked resource for more context and further details.
- Quickly get information on a view you’re looking at:
po [[[UIApplication sharedApplication] keyWindow] recursiveDescription]
- Pick the memory address of the view from the hierarchy.
po id $view = (id)0x123456f9
- To modify that view:
po [$view setBackgroundColor:UIColor.redColor]
- Here’s the trick! Refresh the view with:
[CATransaction flush]
- Couple random things I learned from reading this (and looking a few things up)
po
,p
,e
are all aliases ofexpression
(po
runs command with the-O
option, runhelp expression
for details on what this does). Easy just to runpo
for everything.- With objective-c, I always had a hard time printing objects, but realized the issue is dot notation. Use brackets when running into
property ‘someProperty’ not found on object of type ‘someObject’
- This article adds
(void)
before sending a message to a selector (e.g.(void)[CATransaction flush]
). It keeps from outputting anything, but doesn’t seem necessary. - Adding
--
afterexpression
is only required when you have options (to separate options from code you want to run).