Reveal的使用

2020-03-22  本文已影响0人  lmfei

Reveal是一款不需要重新运行项目,就可以动态调试程序UI界面的工具。

项目中添加Reveal framework进行使用

dyld: Library not loaded: @rpath/RevealServer.framework/RevealServer
  Referenced from: /Users/liumingfei/Library/Developer/CoreSimulator/Devices/C192F1C0-C2FA-4C80-A46C-DA32EC1755C5/data/Containers/Bundle/Application/B12DEA41-B4D0-475E-AA60-2C4051E2DD88/20200308-数据结构&算法.app/20200308-数据结构&算法
  Reason: image not found

通过Build Phases 中新增 New Copy Files Phase,然后将Destination设置为frameworks,点击+,添加RevealServer.framework


Build Phases

再次运行项目,运行成功后,打开Reveal,然后打开对应的关联应用即可


Reveal
可以查看View的结构了
image.png

无侵入使用

打开.lldbinit文件,然后编辑,新增

command alias reveal_load_sim 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];

使用修改生效

command source .lldbinit

打开对应工程,在application:didFinishLaunchingWithOptions:方法中执行如下操作:

  1. 增加一个断点


    增加断点
  2. 右击,选择Edit Breakpoint


    Edit
  3. 点击Add Action


    Add Action
  4. 添加内容reveal_load_sim,并勾选Automatically continue a er evaluating


    reveal_load_sim

    然后运行项目,打开Reveal,打开相关应用即可,这种方案无侵入,推荐使用

越狱设备查看任意App

方法一

  1. Mac端,打开Reveal,在Help->Show Reveal Library in Finder - iOS Library找到RevealServer.framework,然后打开RevealServer.framework找到里面的RevealServer文件,copy一份到自己的目录下然后重命名为RHRevealLoader.dylib

  2. iPhone在Cydia中安装Reveal Loader,重启Spring Board


    Reveal Loader
  3. 将RHRevealLoader.dylib可执行文件拷贝到/Library/MobileSubstrate/DynamicLibraries目录下,防止设备上动态库版本与电脑上版本不一致

scp /Applications/Reveal.app/Contents/SharedSupport/iOS-Libraries/RevealServer.framework/RevealServer root@192.168.1.5:/Library/MobileSubstrate/DynamicLibraries/RHRevealLoader.dylib
  1. iPhone 设置 - Reveal - Enabled Applications 打开想要查看的App即可


    设置
    Reveal

方法二

  1. Mac端,打开Reveal,在Help->Show Reveal Library in Finder - iOS Library找到RevealServer.framework,然后打开RevealServer.framework找到里面的RevealServer文件,copy一份到自己的目录下然后重命名为reveal2Loader.dylib
  2. iPhone在Cydia中安装Reveal2Loader,重启Spring Board


    Reveal2Loader
  3. 将reveal2Loader.dylib可执行文件拷贝到/Library/MobileSubstrate/DynamicLibraries目录下,防止设备上动态库版本与电脑上版本不一致
scp /Applications/Reveal.app/Contents/SharedSupport/iOS-Libraries/RevealServer.framework/RevealServer root@192.168.1.5:/Library/MobileSubstrate/DynamicLibraries/reveal2Loader.dylib
  1. iPhone 设置 - Reveal - Enabled Applications 打开想要查看的App即可

方法三

  1. Mac端,打开Reveal,在Help->Show Reveal Library in Finder - iOS Library找到RevealServer.framework,然后打开RevealServer.framework找到里面的RevealServer文件,copy一份到自己的目录下然后重命名为libReveal.dylib
  2. 生成libReveal.plist文件,其中Bundles为目标应用的BundleID数组,如果不配置改文件,则会监测所有应用导致设备卡顿
{
    Filter = {
        Bundles = (
            "com.xxx.xxx",
        );
    };
}
  1. 将libReveal.dylib可执行文件拷贝到/Library/MobileSubstrate/DynamicLibraries/目录下

打开设置的App,查看效果


可调试的App
App UI

大功告成!!!

生活如此美好,今天就点到为止。。。

上一篇 下一篇

猜你喜欢

热点阅读