使用Reveal来调试模拟器中的我们的App的界面
1、在Xcode中添加 Symbolic Breakpoint
2、在Symbol输入框填上 UIApplicationMain
3、点击Action按钮,设置为 Debugger Command 状态
4、在Action下面文本框中复制以下代码:
expr (Class)NSClassFromString(@"IBARevealLoader") == nil ? (void *)dlopen("/Applications/Reveal.app/Contents/SharedSupport/iOS-Libraries/RevealServer.framework/RevealServer", 0x2) : ((void*)0)
5、勾选 Automatically continue after evaluating actions.
![](https://img.haomeiwen.com/i1738688/08abaffbce71d175.png)
6、右键当前断点,选择Move Breakpoint To → User.(这样不用每次都配置了)
![](https://img.haomeiwen.com/i1738688/83ec40f41b10cec5.png)
使用Reveal来调试真机中的我们的App的界面(两种方式)
CocoaPods
pod 'Reveal-SDK', :configurations => ['Debug']
这个 :configurations
属性是为了保证 Reveal 只链接到你项目的 Debug 构建版本
注:如果 pod 的 Reveal-SDK版本高于Mac里面的 Reveal 版本的话,调试不了,会提示让你去升级,可以根据你的 Reveal 的版本导入同样的版本,比如我的 mac 上的 Reveal 版本是 13,可以改成以下的 pod 语句:
pod 'Reveal-SDK', '13', :configurations => ['Debug']
手动配置
1、打开 Reveal,选择 "Help -> show Reveal Library in Finder ->iOS Library"
2、拷贝 RevealServer.framework 到你的项目的根目录
![](https://img.haomeiwen.com/i1738688/4277c3f3d8f11030.jpg)
3、在 Xcode 中打开你的项目
4、选择你想要使用 Reveal 的 Target
5、 点击Build Settings ,在 Framework Search Paths 的 Debug 配置中添加
$(inherited) $(SRCROOT)
![](https://img.haomeiwen.com/i1738688/46762f8ea3c7a5ea.jpg)
6、 在 Other Linker Flags 的 Debug 配置中添加
-ObjC -weak_framework RevealServer
![](https://img.haomeiwen.com/i1738688/367dffb58271aa5c.jpg)
7、在 Runpath Search Paths 的 Debug 配置中添加
$(inherited) @executable_path/Frameworks
8、点击 Build Phases ,添加 New Run Script phase
,并将下面的shell脚本粘贴进去
export REVEAL_SERVER_FILENAME="RevealServer.framework"
# Update this path to point to the location of RevealServer.framework in your project.
export REVEAL_SERVER_PATH="${SRCROOT}/${REVEAL_SERVER_FILENAME}"
# If configuration is not Debug, skip this script.
[ "${CONFIGURATION}" != "Debug" ] && exit 0
# If RevealServer.framework exists at the specified path, run code signing script.
if [ -d "${REVEAL_SERVER_PATH}" ]; then
"${REVEAL_SERVER_PATH}/Scripts/copy_and_codesign_revealserver.sh"
else
echo "Reveal Server not loaded: RevealServer.framework could not be found."
fi
如果你的 RevealServer.framework 不在项目的根目录的话,将
REVEAL_SERVER_PATH
修改成你项目里的路径
![](https://img.haomeiwen.com/i1738688/a9ff91a8139cf5d5.jpg)
9、在 Xcode 运行你的项目,确保真机和mac处于同一 wifi 环境下,或者通过 USB 连接。运行完项目,打开 Reveal,你可以看到你的项目,双击打开就可以调试你的项目了。
网友评论