未完待续,[继续总结]html
lldb与gdb命令对比git
功能 | 命令 |
---|---|
暂停/继续 | cmd + ctrl + Y |
断点失效/生效 | cmd + Y |
控制台显示/隐藏 | cmd + shift + Y |
光标切换到控制台 | cmd + shift + C |
清空控制台 | cmd + K |
step over | F6 |
step into | F7 |
step out | F8 |
//swift版
func DLog<T>(message: T, file: String = #file, method: String = #function, line: Int = #line) {
#if DEBUG
print("<\((file as NSString).lastPathComponent) : \(line)>, \(method) \(message)")
#endif
}
//OC版
#ifdef DEBUG
#define DLog(fmt, ...) NSLog((@"<%s : %d> %s " fmt), [[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, __PRETTY_FUNCTION__, ##__VA_ARGS__);
#else
#define DLog(...)
#endif
复制代码
设置断点触发条件 github
注意: ![]()
// 正确
(BOOL)[pId isEqualToString:@"short-videopage"]
// 报错:error: no known method '-isEqualToString:'; cast the message send to the method's return type [pId isEqualToString:@"short-videopage"] 复制代码
在调试登陆相关的bug时,很是方便,不用担忧常常输密码,还输错的尴尬 数据库
调试UI,改变指定控件的颜色 ![]()
![]()
当咱们查看一个陌生的项目的时候,咱们能够先运行APP,对全部的
viewDidLoad
函数添加断点,进而了解代码执行路径 express![]()
![]()
Symbol
:符号
methodName
只须要写函数名,不用写后面的()[className methodName]
className是类名,methodName是方法名(不区分类方法和实例方法)ClassName.methodName
Module
模块筛选:能够避免不一样库中方法名或者函数名相同 Condition
触发条件swift
这里能够添加一些指定触发条件,好比添加第一个参数(arg3)不能为nil。这里arg4表明第2个参数,以此类推。这里也能够调用方法来判断,但必须是类方法,而且返回值必须为BOOL类型。 样例:找出给[UIImage imageNamed:]传nil的代码。这里就须要设置Symbol为
[UIImage imageNamed:]
,而后Condition设置为$arg3 == nil
。这样在运行中若是遇到传nil就会触发断点。 xcode查看某一个函数须要添加断点的符号填写格式(在须要调试的函数打上断点,程序运行走到断点后,从堆栈信息中查看相应函数的格式) ![]()
若是电脑配置较低,最好使用
chisel
插件命令pviews
bash![]()
遇到EXC_BAD_ACCESS这个错误,那就意味着你向一个已经释放的对象发送消息。Xcode知道这个对象是什么,因此可让咱们知道这个对象在哪里,以及这是何时发生的。当开启僵尸模式后,遇到EXC_BAD_ACCESS,xcode能够帮咱们快速定位到出现问题的代码。网络
开启僵尸模式: app
导入@import UIKit
(lldb) p self.view.frame
error: property 'frame' not found on object of type 'UIView *'
error: 1 errors parsing expression
(lldb) e @import UIKit
(lldb) p self.view.frame
(CGRect) $0 = (origin = (x = 0, y = 0), size = (width = 375, height = 667))
复制代码
或者(CGRect)
print (CGRect)[view frame]
(CGRect) $1 = (origin = (x = 0, y = 0), size = (width = 200, height = 100))
复制代码
UIAppliaction
.h文件
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
@interface CustomApplication : UIApplication
@end
NS_ASSUME_NONNULL_END
复制代码
.m文件
#import "CustomApplication.h"
@implementation CustomApplication
-(void)sendEvent:(UIEvent *)event {
[super sendEvent:event];
}
@end
复制代码
main.m文件
#import <UIKit/UIKit.h>
#import "AppDelegate.h"
#import "CustomApplication.h"
int main(int argc, char * argv[]) {
@autoreleasepool {
return UIApplicationMain(argc,
argv,
NSStringFromClass([CustomApplication class]),
NSStringFromClass([AppDelegate class]));
}
}
复制代码
一次事件可能会执行三次函数:
-(void)sendEvent:(UIEvent *)event
三次的force
有区别![]()
一次事件可能会执行两次函数:
-(void)sendEvent:(UIEvent *)event
两次的force
没区别![]()
一、若是是
UIControl
事件,集成UIResponder
控件(UIButton
)消息传递链(倒序)以下图所示![]()
二、若是是
UIGestureRecognizer
手势事件,集成UIResponder
控件(UIView
)消息传递链(倒序)以下图所示![]()
三、若是
UIControl
和UIGestureRecognizer
同时存在,优先级高![]()
Chisel是faceBook开源的lldb调试命令集合
Chisel 使用 homebrew 来安装
brew update
brew install chisel
复制代码
安装完成后,将下面的命令添加到~/.lldbinit
中,xcode启动的时候才会加载chisel
command script import /usr/local/opt/chisel/libexec/fblldb.py
复制代码
经常使用命令
(lldb) help
复制代码
Reveal 绝对是iOS界面调试利器。使用起来不只比Xcode自带流畅,并且功能更加多。因为收费,30天事后就没怎么用可是绝对好用。
FLEX是Flipboard开源的一系列在应用中调试的工具集。FLEX以第三方库的形式集成在应用中,使用时将类库加到工程中,而后 经过调用[[FLEXManager sharedManager] showExplorer]; 就可显示出用于调试的工具栏进行调试。
它提供的功能以下: