在iOS应用开发中,可以使用Reveal查看视图的层级以及修改视图的属性(虽然xcode自带的工具也可以查看,但是功能却没有Reveal强大),还可以使用越狱手机查看其它应用的结构等.
提供一个Reveal的下载地址:Reveal
模拟器调试
- 1.在
XCode中选择View→Navigators→Show Breakpoint Navigator. - 2.添加
Symbolic Breakpoint - 3.
Symbol中填入UIApplicationMain - 4.选择
Add Action按钮 - 5.填入下列内容
expr (Class)NSClassFromString(@"IBARevealLoader") == nil ? (void *)dlopen("/Applications/Reveal.app/Contents/SharedSupport/iOS-Libraries/RevealServer.framework/RevealServer", 0x2) : ((void*)0)
- 6.勾选
Automatically continue after evaluating actions

BreakPoint
- 7.右键选择断点,选择
Move Breakpoint To→User - 8.在
XCode中运行程序
#### 真机调试(未越狱)
- 1.查找
RevealServer.framework所在位置,在Reveal中Help→Show Reveal Library in Finder

RevealServer.framework
- 2.将
RevealServer.framework拷贝到项目的根目录中 - 3.使用
XCode打开项目,选择要操作的TARGETS

image.png
- 4.选择
Build Settings,在Framework Search Paths的Debug模式下设置:
$(inherited) $(SRCROOT)

Framework Search Paths
- 5.选择
Build Settings,在Runpath Search Paths的Debug模式下设置:
$(inherited) @executable_path/Frameworks
- 6.选择
Build Phases,添加Run Script

Run Script
- 7.在
Run Script添加如下代码
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 "Cannot find RevealServer.framework, so Reveal Server will not be started for your app."
fi
- 8.在
Debug模式下运行项目
Reveal.png
