在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
- 7.右键选择断点,选择
Move Breakpoint To
→User
- 8.在
XCode
中运行程序
#### 真机调试(未越狱)
- 1.查找
RevealServer.framework
所在位置,在Reveal
中Help
→Show Reveal Library in Finder
- 2.将
RevealServer.framework
拷贝到项目的根目录中 - 3.使用
XCode
打开项目,选择要操作的TARGETS
- 4.选择
Build Settings
,在Framework Search Paths
的Debug
模式下设置:
$(inherited) $(SRCROOT)
- 5.选择
Build Settings
,在Runpath Search Paths
的Debug
模式下设置:
$(inherited) @executable_path/Frameworks
- 6.选择
Build Phases
,添加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
模式下运行项目