最近闲来无事,网上随便看些大婶写的帖子,发现大婶们都喜欢写一些文章记录自己的工作中遇到的技术难点和工作中的一些杂谈。我没这个习惯,撸代码的时候遇到的难题解决了从来没去总结过,导致下次遇到同样的问题还是去网上找答案。通过看大婶们的帖子,我觉得这个方法很不错,写些文章即是自己学习的总结也能下次遇到同样的问题直接来看自己的帖子就好了。所以我做了一个惊天的决定-----开始写文章(哈哈哈~~~~)。语言组织能力不行,不会讲笑话,别人讲笑话从来不笑(不信你们给讲个,绝对不笑),总之以后得博客技术博客为主,技术大家肯定能懂的哈,就这吧,这也算是开张了(写帖子),不闲扯了 。
进入今天正题 chisel,算起来撸代码也有3年有余了,平时调试程序都是用断点调试,代码中加各种nslog ,看起来既繁琐效率又低,浪费大把的时间花费在调试程序上。
Chisel简介
我们先来看官方给的介绍 Chisel is a collection of LLDB commands to assist in the debugging of iOS apps. 我们知道Chisel是LLDB调试的插件,通过使用Chisel命令能在控制台尽量直观的看到界面元素和情况,便于我们梳理视图 控制器和类之间的层级关系。
Chisel安装
方法一 使用brew安装
brew update
brew install chisel
方法二 使用git安装
git clone https://github.com/facebook/chisel.git ~/.chisel
方法一或者方法二任选其一进行完成之后 需要找到fblldb.py的路径 我的fblldb.py的路径
命令行执行 echo"command script import /usr/local/opt/chisel/libexec/fblldb.py">>~/.lldbinit
安装好之后 重启Xcode 在代码任意位置加断点 log输出位置输入 help命令 出现 如下图
这样就说明安装成功了~~~
基本命令介绍
先把上面help命令之后得到的 命令粘贴出来
Current user-defined commands:
alamborder -- For more information run 'help alamborder'
alamunborder -- For more information run 'help alamunborder'
binside -- For more information run 'help binside'
bmessage -- For more information run 'help bmessage'
border -- For more information run 'help border'
caflush -- For more information run 'help caflush'
dcomponents -- For more information run 'help dcomponents'
dismiss -- Dismiss a presented view controller.
eobjc -- For more information run 'help eobjc'
eswift -- For more information run 'help eswift'
fa11y -- For more information run 'help fa11y'
flicker -- For more information run 'help flicker'
fv -- For more information run 'help fv'
fvc -- For more information run 'help fvc'
hide -- For more information run 'help hide'
mask -- For more information run 'help mask'
mwarning -- For more information run 'help mwarning'
pa11y -- For more information run 'help pa11y'
pa11yi -- Print accessibility identifiers of all views in hierarchy
ofpactions -- For more information run 'help pactions'
paltrace -- For more information run 'help paltrace'
panim -- For more information run 'help panim'
pbcopy -- Print object and copy output to clipboard
pblock -- Print the block`s implementation address and signature
pbundlepath -- Print application's bundle directory path.
pca -- For more information run 'help pca'
pcells -- For more information run 'help pcells'
pclass -- For more information run 'help pclass'
pcomponents -- For more information run 'help pcomponents'
pcurl -- For more information run 'help pcurl'
pdata -- For more information run 'help pdata'
pdocspath -- For more information run 'help pdocspath'
pinternals -- For more information run 'help pinternals'
pinvocation -- For more information run 'help pinvocation'
pivar -- For more information run 'help pivar'
pjson -- For more information run 'help pjson'
pkp -- For more information run 'help pkp'
pmethods -- For more information run 'help pmethods'
pobjc -- For more information run 'help pobjc'
poobjc -- For more information run 'help poobjc'
poswift -- For more information run 'help poswift'
pproperties -- Print the properties of an instance or Class
present -- Present a view controller.
presponder -- For more information run 'help presponder'
pswift -- For more information run 'help pswift'
ptv -- For more information run 'help ptv'
pvc -- For more information run 'help pvc'
pviews -- For more information run 'help pviews'
rcomponents -- For more information run 'help rcomponents'
setinput -- Input text into text field or text view that is first responder.
settext -- Set text on text on a view by accessibility id.
show -- For more information run 'help show'
slowanim -- For more information run 'help slowanim'
taplog -- For more information run 'help taplog'
unborder -- For more information run 'help unborder'
unmask -- For more information run 'help unmask'
unslowanim -- For more information run 'help unslowanim'
visualize -- For more information run 'help visualize'
vs -- For more information run 'help vs'
wivar -- For more information run 'help wivar'
For more information on any command, type 'help'.
visualize 命令
预览图片命令
UIImage*image = [UIImageimageNamed:@"图片名字"];
UIImageView*imageView = [[UIImageViewalloc] initWithImage:image];
[self.view addSubview:imageView];
执行 visualize image 命令后 图片会被苹果自带的预览工具显示出来
pclass命令
关系链的继承关系
(lldb) pclass image
UIImage | NSObject
(lldb)
命令详细这块感觉有篇文章介绍的很详细 我就不再重复介绍了,附上大婶的文章链接 小笨狼的LLDB技巧:chisel
参考文章
网友评论