下载地址(https://revealapp.com/download-thanks/)
使用Reaveal连接模拟器调试
- 打开Terminal,输入vim ~/.lldbinit 创建一个名为.lldbinit的文件,然后将如下内容输入该文件中:
command alias reveal_loadsim expr (void*)dlopen("Applications/Reveal.app/Contents/SharedSupport/iOS-Libraries/libReveal.dylib", 0x2);
command alias reveal_load_dev expr (void*)dlopen([(NSString*)[(NSBundle*)[NSBundle mainBundle] pathForResource:@"libReveal" ofType:@"dylib"] cStringUsingEncoding:0x4], 0x2);
command alias reveal_start expr (void)[(NSNotificationCenter*)[NSNotificationCenter defaultCenter] postNotificationName:@"IBARevealRequestStart" object:nil];
command alias reveal_stop expr (void)[(NSNotificationCenter*)[NSNotificationCenter defaultCenter] postNotificationName:@"IBARevealRequestStop" object:nil];
该步骤其实是为lldb设置4个别名,这样方便后续操作。这4个别名的意义如下:
- reveal_load_sim 为模拟器加载reveal调试的动态链接库
- reveal_load_dev 为真机加载reveal调试用的动态链接库
- reveal_start 启动reveal调试功能
- reveal_stop 结束reveal调试功能
- 在AppDelegate类的Application:didFinishLaunchingWithOptions:方法中进行下面三步操作
-
添加断点
-
编辑断点,点击add Action,输入reveal_load_sim
-
勾选Automatically continue after evaluating action
截屏2021-11-09 下午4.48.42.png
-
运行模拟器,打开reveal,就可以在界面上左上角看到有模拟器可以连接调试,选择它,则可以在Reveal中查看调试该程序界面
真机调试
-
将动态链接库添加到工程里
在Reveal-Help->Show Reveal Library in Finder 找到链接库libReveal.dylib
拖拽进工程会被错误的添加到Link Binary With Libraries下,我们需要删除,将其添加到Copy Bundle Resources下面 -
将断点的action改为reveal_load_dev即可
网友评论