Using the Chisel LLDB Plugin for iOS Debugging: Installation, Commands, and Tips
This guide introduces the open‑source LLDB debugger and the Facebook‑maintained Chisel plugin for iOS, covering installation via Homebrew, configuration of .lldbinit, and a comprehensive set of custom commands that simplify UI inspection, view hierarchy analysis, and autolayout debugging within Xcode.
LLDB is an open‑source debugger with REPL capabilities and C++/Python plugins, integrated into Xcode’s console, allowing you to pause execution, inspect variables, and run custom commands.
Installation steps are:
brew update
brew install chisel
Create ~/.lldbinit and add command script import /usr/local/opt/chisel/libexec/fblldb.py , then restart Xcode.
After restarting, the Chisel plugin provides many convenient commands for UI debugging.
Print commands (group “Print”):
pviews – recursively prints all views with hierarchy.
pvc – recursively prints view controllers.
ptv – prints the visible tableView.
pcells – prints visible cells of a tableView.
pdata – decodes and prints NSData.
po – prints an object using its description.
Find commands (group “Find”):
fvc – search memory for views matching a class name regex.
fv – search for view controller instances by class name.
taplog – after pausing, click a view to log its details.
vs – locate a view in the view hierarchy and show its screen position.
Display commands (group “Display”):
caflush – refresh UI after LLDB‑driven changes.
border – add a border to a view or layer. Usage: Syntax: border [--color=color] [--width=width] <viewOrLayer>
mask – add a semi‑transparent mask to a view. Usage: Syntax: mask [--color=color] [--alpha=alpha] <viewOrLayer>
show – make a hidden view visible (sets view.hidden = NO ).
Preview command (group “Preview”):
visualize – opens UIImage, CGImageRef, UIView, CALayer, etc., in macOS Preview. Usage: Syntax: visualize <target>
Debug commands (group “Debug”):
bmessage – set a breakpoint on a method name without specifying the class. Usage: Syntax: bmessage <expression>
wivar – set a watchpoint on an instance variable. Usage: Syntax: wivar <object> <ivarName>
Autolayout commands (group “Autolayout”):
hasAmbiguousLayout – checks for ambiguous layouts.
_autolayoutTrace – finds ambiguous layout instances.
alamborder – adds a colored border to views with ambiguous layouts. Usage: Syntax: alamborder [--color=color] [--width=width]
alamunborder – removes borders added by alamborder .
Other useful command :
paltrace – prints detailed autolayout information for a view (defaults to keyWindow). Usage: Syntax: paltrace <view>
The article demonstrates how Chisel’s commands can replace verbose NSLog statements, streamline UI inspection, and encourages exploring the full command set in the GitHub repository: https://github.com/facebook/chisel .
360 Quality & Efficiency
360 Quality & Efficiency focuses on seamlessly integrating quality and efficiency in R&D, sharing 360’s internal best practices with industry peers to foster collaboration among Chinese enterprises and drive greater efficiency value.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.