在iOS
應(yīng)用開發(fā)中,可以使用Reveal
查看視圖的層級以及修改視圖的屬性(雖然xcode
自帶的工具也可以查看,但是功能卻沒有Reveal
強(qiáng)大),還可以使用越獄手機(jī)查看其它應(yīng)用的結(jié)構(gòu)等.
提供一個Reveal
的下載地址:Reveal
模擬器調(diào)試
- 1.在
XCode
中選擇View
→Navigators
→Show Breakpoint Navigator
. - 2.添加
Symbolic Breakpoint
- 3.
Symbol
中填入UIApplicationMain
- 4.選擇
Add Action
按鈕 - 5.填入下列內(nèi)容
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.右鍵選擇斷點(diǎn),選擇
Move Breakpoint To
→User
- 8.在
XCode
中運(yùn)行程序
#### 真機(jī)調(diào)試(未越獄)
- 1.查找
RevealServer.framework
所在位置,在Reveal
中Help
→Show Reveal Library in Finder
RevealServer.framework
- 2.將
RevealServer.framework
拷貝到項(xiàng)目的根目錄中 - 3.使用
XCode
打開項(xiàng)目,選擇要操作的TARGETS
image.png
- 4.選擇
Build Settings
,在Framework Search Paths
的Debug
模式下設(shè)置:
$(inherited) $(SRCROOT)
Framework Search Paths
- 5.選擇
Build Settings
,在Runpath Search Paths
的Debug
模式下設(shè)置:
$(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
模式下運(yùn)行項(xiàng)目
Reveal.png