Reveal簡介:
Reveal是一款iOS界面調試工具,輔助Xcode進行界面調試,使用它可以在iOS開發的時候動态的檢視和修改應用程式的界面。
軟體下載下傳
官網下載下傳位址:https://revealapp.com/download/
應用圖示如下所示:
使用場景:
一、對于複雜的UI界面,一般我們使用純代碼進行布局,但是每次修改完代碼都需要重新啟動模拟器或者真機才能看到效果,相對比較麻煩;
二、當我們想要學習别人如何實作界面效果的時候
多種內建方式:
一: 使用CocoaPods
使用CocoaPods是最簡單的內建方法,尤其适合團隊開發,具體的步驟如下:
添加下面的文版到你的 Podfile 檔案:
target 'YourMainAppTargetName' do
pod 'Reveal-SDK', :configurations => ['Debug']
end
執行:pod install
或者:pod update
在項目的根目錄下執行 pod install 指令(如果之前已經在項目中使用了Cocoapods,執行 pod update 指令)
二: 通過給Xcode配置斷點
适用範圍:隻适用于在模拟器上檢視應用
1、使用快捷鍵 command+7 或者通過點選菜單 View → Navigators → Show Breakpoint Navigator 進入斷點設定導航下
2、添加斷點
3、設定斷點參數
在 1 處寫入UIApplicationMain
在 2 處點選 Add Action 按鈕,複制下面的文字到輸入框内
iOS targets:
expr (Class)NSClassFromString(@"IBARevealLoader") == nil ? (void *)dlopen("/Applications/Reveal.app/Contents/SharedSupport/iOS-Libraries/RevealServer.framework/RevealServer", ) : ((void*))
tvOS targets:
expr (Class)NSClassFromString(@"IBARevealLoader") == nil ? (void *)dlopen("/Applications/Reveal.app/Contents/SharedSupport/iOS-Libraries/RevealServer.framework/RevealServer", ) : ((void*))
最後 勾選上 Automatically continue after evaluating actions 項
最終的結果如下圖所示:
4、右擊,如下圖所示進行設定:
設定完成,此時運作程式在模拟器中,打開Reveal,就能看見自己的APP的界面了:
三:連結RevealServer.framework 到應用程式
使用方法二隻能檢視模拟器上應用,如果想檢視真機的界面,需要使用這種方法設定,
具體步驟如下:
1、找到RevealServer.framework庫到程式的根目錄下
2、導入庫到程式的根目錄下
3、Xcode配置
點選 TARGETS, 選中 Build Settings,
a、輸入 Framework Search Paths,在Debeg行設定:
$(inherited) $(SRCROOT)
b、輸入 Other Linker Flags,在Debeg行設定
-ObjC -lz -weak_framework RevealServer
c、輸入 Runpath Search Paths,檢查設定是否如下所示
效果圖:
點選 TARGETS, 選中 Build Phases,添加一個新的 Run 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
效果圖:
添加一個 Run Script
最終如下圖:
此時在真機上運作程式,便會在Reveal上看到自己的APP了,大功告成,如下圖所示:
注意:一定保證真機和電腦在同一個WIFI下!!!