1、WWDC2018
1.1 Advanced Debugging with Xcode and LLDB link
Discover advanced techniques, and tips and tricks for enhancing your Xcode debugging workflows. Learn how to take advantage of LLDB and custom breakpoints for more powerful debugging. Get the most out of Xcode's view debugging tools to solve UI issues in your app more efficiently.
1.2 視頻介紹的內(nèi)容
- 每次啟動app再到響應(yīng)的測試業(yè)務(wù)需要經(jīng)過很多個步驟龟劲,使用LLDB調(diào)試可以減少這個時(shí)間花費(fèi)
- 這個步驟是可以直接拖動跳過的
#跳過響應(yīng)的執(zhí)行行數(shù)
thread jump --by 2
#跳過之后可以執(zhí)行預(yù)期需要執(zhí)行的代碼
expression [self.view setBackgroudColor:[UIColor redColor]]
- 介紹了LLDB的常用指令
(lldb) p & po (lldb) expression & e (lldb) frame variable <name>
- 介紹了LLDB 執(zhí)行 Python,快捷LLDB腳本集合Chisel
- 介紹了Xcode來調(diào)試UI界面颓屑,直接頁面操作copy響應(yīng)視圖或者約束
2、Chisel功能使用
2.1 chisel集成
#1.安裝
brew update
brew install chisel
#這里如果出現(xiàn)錯誤按照提示解決
#Cannot brew update or upgrade: Error: homebrew-cask is a shallow clone
#https://github.com/Homebrew/brew/issues/9420
#2.根目錄創(chuàng)建llbdinit文件
touch .lldbinit
open .lldbinit
#3.集成Chisel python腳本集合
command script import /usr/local/opt/chisel/libexec/fbchisellldb.py
#4.重啟xcode,在Xcode輸入pviews查看視圖結(jié)構(gòu) | help查看指令
2.2 腳本常用指令
There are many commands; here's a few: (Compatibility with iOS/Mac indicated at right)
Command | Description | iOS | OS X |
---|---|---|---|
pviews | Print the recursive view description for the key window. | Yes | Yes |
pvc | Print the recursive view controller description for the key window. | Yes | No |
visualize | Open a UIImage , CGImageRef , UIView , CALayer , NSData (of an image), UIColor , CIColor , or CGColorRef in Preview.app on your Mac. |
Yes | No |
fv | Find a view in the hierarchy whose class name matches the provided regex. | Yes | No |
fvc | Find a view controller in the hierarchy whose class name matches the provided regex. | Yes | No |
show/hide | Show or hide the given view or layer. You don't even have to continue the process to see the changes! | Yes | Yes |
mask/unmask | Overlay a view or layer with a transparent rectangle to visualize where it is. | Yes | No |
border/unborder | Add a border to a view or layer to visualize where it is. | Yes | Yes |
caflush | Flush the render server (equivalent to a "repaint" if no animations are in-flight). | Yes | Yes |
bmessage | Set a symbolic breakpoint on the method of a class or the method of an instance without worrying which class in the hierarchy actually implements the method. | Yes | Yes |
wivar | Set a watchpoint on an instance variable of an object. | Yes | Yes |
presponder | Print the responder chain starting from the given object. | Yes | Yes |
更多指令介紹:Wiki