iOS中的UI调试工具:Reveal 11集成和使用
2017-11-27 本文已影响0人
kangyiii
Reveal是什么?
Reveal功能类似于Xcode自带的Debug View Hierarchy(视图层次结构),但相较于Debug View Hierarchy,Reveal不仅可以直观的看到UI布局,还能实时的修改它以便达到最佳的显示效果,就像Firefox中的fireDug一样。


Reveal 11(2017.11最新版)的集成和使用方法
目前有三种集成方法:
1.使用CocoaPods 2.手动将Framework导入工程 3.打断点
1.使用CocoaPods,不知道CocoaPods的同学们戳这里
这种方式适合于团队开发时开发人员都使用Reveal的场景。
Podfile需要导入的框架如下:
target 'YourMainAppTargetName' do
pod 'Reveal-SDK', :configurations => ['Debug']
end
注意:请确保只在调试环境下将Reveal Server framework导入到您的环境中。
configurations => ['Debug']:配置这个参数可以确保Reveal只会链接到你的调试版本。
2.手动将Framework导入工程
1.从Reveal取出适用于iOS的Revel框架,并将它放入您项目的根目录。


2.配置您的Xcode工程:
配置1:Targets->Build Setting->Search Paths->Framework Search Paths->Dubug->键入:
$(inherited) $(SRCROOT)
;
配置2:Targets->Build Setting->Other Linker Flags->Dubug->键入:
-ObjC -weak_framework RevealServer

配置3:请确认您的Targets->Build Setting->Runpath Search Paths ->Dubug中有:
$(inherited) @executable_path/Frameworks
配置4:Targets->BuildPhases->new Run Script phase 中写入以下script,并重命名为
Integrate Reveal Server
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

3.关闭重新打开xcode并运行您的工程,在Reveal中就能看到相应的UI布局。
注意:请确认您的电脑和调试设备处在同一局域网下
3.打断点
1.在Reveal中打开Help主菜单->点击Install Debugger Commands。点击Continue
2.xcode中添加断点

3.配置断点
配置1:Symbol键入: UIApplicationMain
Action键入:reveal load

配置2:右键单击新创建的断点,Move Breakpoint To -> User。

4.真机调试时额外需要一个步骤:Targets->BuildPhases->new Run Script phase 中写入以下script,并重命名为Integrate Reveal Server
:
REVEAL_APP_PATH=$(mdfind kMDItemCFBundleIdentifier="com.ittybittyapps.Reveal2" | head -n 1)
BUILD_SCRIPT_PATH="${REVEAL_APP_PATH}/Contents/SharedSupport/Scripts/reveal_server_build_phase.sh"
if [ "${REVEAL_APP_PATH}" -a -e "${BUILD_SCRIPT_PATH}" ]; then
"${BUILD_SCRIPT_PATH}"
else
echo "Reveal Server not loaded: Cannot find a compatible Reveal app."
fi
