iOS界面調試工具 Reveal --該文作者唐巧
Reveal的使用
用Reveal連接模擬器調試
Reveal官方介紹了好幾種辦法使Reveal連接模擬器,都需要修改工程文件。但如果修改了工程文件,就需要參與項目開發的所有人都裝有Reveal,這其實是相當不友好的。本節要介紹一種不修改任何工程文件的辦法,在實際使用中,這種辦法最簡單方便。該方法的步驟如下:
首先打開Terminal,輸入 vim ~/.lldbinit 創建一個名為.lldbinit的文件,然后將如下內容輸入到該文件中:
command alias reveal_load_sim expr (void*)dlopen("/Applications/Reveal.app/Contents/SharedSupport/iOS-Libraries/libReveal.dylib", 0x2);
command alias reveal_load_dev expr (void*)dlopen([(NSString*)[(NSBundle*)[NSBundle mainBundle] pathForResource:@"libReveal" ofType:@"dylib"] cStringUsingEncoding:0x4], 0x2);
command alias reveal_start expr (void)[(NSNotificationCenter*)[NSNotificationCenter defaultCenter] postNotificationName:@"IBARevealRequestStart" object:nil];
command alias reveal_stop expr (void)[(NSNotificationCenter*)[NSNotificationCenter defaultCenter] postNotificationName:@"IBARevealRequestStop" object:nil];
該步驟其實是為lldb設置了4個別名,為了后續方便操作,這4個別名意義如下:
reveal_load_sim 為模擬器加載reveal調試用的動態鏈接庫
reveal_load_dev 為真機加載reveal調試用的動態鏈接庫
reveal_start 啟動reveal調試功能
reveal_stop 結束reveal調試功能
接下來,我們在AppDelegate類的 application: didFinishLaunchingWithOptions:
方法中,作如下3步操作(如下圖所示):
點擊該方法左邊的行號區域,增加一個斷點,之后右擊該斷點,選擇“Edit Breakpoint”。
點擊”Action”項邊右的”Add Action”,然后輸入“reveal_load_sim”
勾選上Options上的”Automatically continue after evaluating”選項。
101B0359-0B3F-44CD-A77A-C8F5DF069E62.png
之后我們運行模擬器,然后打開Reveal,就可以在Reveal界面的左上角,看到有模擬器可以連接調試,選擇它,則可以在Reveal中查看和調試該iOS程序的界面了。
A9AEC8FB-B085-4B11-ACB5-40673FCBB312.png
更多請查看文章開頭鏈接!
end!