In the film Taken, Liam Neeson has a particular set of skills. Mr. Neeson tracks down various people and provides a personal demonstration of the merit of these skills. As his skill-set quickly resolves his major blocker (a kidnapped daughter), so too will software developers' debugging skills pay off in the field (hopefully without the violence.) The worthy developer will value what enhances his debugging powers.
Dancing in the Debugger covers potent debugging skills for the LLDB command line; for me the good stuff starts about 3/4 into the article (it’s all valuable!)
To summarize: Have you ever wanted to pause your running iOS app in Xcode to manipulate and better understand all the visual elements on screen, or conveniently change variable values and see results without stopping, recompiling, and running the app again? How about setting breakpoints from the command line?
Like Bruce Lee's nun-chucks, Chisel is the perfect compliment to your LLDB bug-fu. Some fine Facebook folk shared their commonly used LLDB debugging commands in the form of python scripts so that you can type (in the LLDB debugger command line)...
"po [[[UIApplication sharedApplication] keyWindow] recursiveDescription]”
...to see your app’s current UI hierarchical tree print to the console!
Or, let’s say I have just run the above command and printed this big hierarchical list of UI elements. Instead of sorting through this big dump of objects for a UISegmentedControl I can just type...
(lldb) fv segmented
Now just grab that address and go to town…
e id $mySegmentedControl = (id)0x7fd72ac3ba90
That just created the convenience variable $mySegmentedControl. Here is the current control:
Let's change a color...
(lldb) e (void)[$mySegmentedControl setBackgroundColor:(UIColor *)[UIColor redColor]]
...the background color changed to red without even resuming in the debugger!
A single tear runs down your cheek. Try it out! Just read the article and install Chisel - you’ll be glad you did.
By the way, to grab those controller images just above, all I did was type:
(lldb) visualize $mySegmentedControl
The Preview app opens up showing your snapshot of the object. BOOM!