Reveal使我们不但可以在运行时看到iOS程序的界面层级关系,还可以实时的修改程序界面,不用重新运行程序就可以看到修改之后的结果。
在使用时,我们将Reveal连接上模拟器上正在运行的iOS程序,然后就可以查看调试iOS程序的界面。
下面就通过在Xcode上添加断点的方式连接最新版的Reveal,这是我在Reveal官网上看到的最简单的运行模式了。
-
在Xcode中选择 View → Navigators → Show Breakpoint Navigator
-
点击左下角添加断点的加号,选择 Symbolic Breakpoint
-
Symbol填入UIApplicationMain
-
点击Add Action,确保 Action 是选择的 Debugger Command
-
将下面的代码复制到Debugger Command下的输入框
iOS targets:
expr (Class)NSClassFromString(@"IBARevealLoader") == nil ? (void *)dlopen("/Applications/Reveal.app/Contents/SharedSupport/iOS-Libraries/RevealServer.framework/RevealServer", 0x2) : ((void*)0)
复制代码
tvOS targets:
expr (Class)NSClassFromString(@"IBARevealLoader") == nil ? (void *)dlopen("/Applications/Reveal.app/Contents/SharedSupport/tvOS-Libraries/RevealServer.framework/RevealServer", 0x2) : ((void*)0)
复制代码
- 选中 Automatically continue after evaluating actions
- 右键新创建的断点,选择 Move Breakpoint To → User
- 模拟器运行项目,然后在Reveal中会出现我们的项目