啓動Instrument
Instruments應用程序存在於Xcode應用程序中,所以最直接的啓動方式是在Xcode中。 您也可以通過Dock,Launchpad或命令行間接啓動它。
一、從Xcode啓動
啓動instruments的最直接的方式從xcode菜單欄裏啓動.
打開xcode
選擇 Xcode > Open Developer Tool > Instruments.
您還可以啓動Instruments來分析您在Xcode中正在使用的應用程序。.
在xcode打開您的項目
執行下面任意一項:
選擇 Product > Profile.
點擊並按住Xcode工具欄中的運行按鈕並選擇Profile.
按 Command-I.
然後Xcode開始編譯您的項目,Instruments啓動,然後Instruments會提示您去選擇要分析的模板(例如:內存、時間)
如果你經常需要使用相同的模板去分析您的app,那麼您可以將Xcode項目設置爲在啓動分析時自動使用它。設置Xcode項目以使用特定的Instruments分析模板
選擇 Product > Scheme > Edit Scheme.
或者,從Xcode工具欄的Scheme彈出菜單中選擇Edit Scheme
或者,按下 Command–Less Than (<).
出現Scheme編輯器對話框如下:
點擊側欄的profile
在info 選項下面,點擊Instrument 彈出選擇欄,選擇需要的測試模板
如果選擇“啓動時詢問”,Instruments會在啓動時顯示其分析模板選擇對話框。
點擊關閉
開始分析. See To profile an opened Xcode project.
Xcode構建您的項目,啓動Instrument,然後開始按照您在編輯scheme了的配置模板進行分析。
二、Dock啓動
Instruments可以從Dock中的Xcode圖標啓動
打開Xcode.
按住Control鍵並點按Dock中的Xcode圖標,然後從快捷菜單中選擇 Open Developer Tool > Instruments
您也可以將Instruments添加到Dock以便快速訪問。 最快的方法是啓動Instruments,然後將其設置爲停留在Dock中。
打開Xcode
選擇 Xcode > Open Developer Tool > Instruments.
Instruments啓動並且其圖標出現在您的Dock中
按住Control鍵並點按Dock中的Instruments圖標,然後從快捷菜單中選擇 Options > Keep in Dock
三、Launchpad啓動
Launchpad 不直接顯示Instruments,因爲Instruments在Xcode中集成的。你可以手動的把Instruments放到Launchpad裏面。
添加Instruments到Launchpad步驟如下:
打開Xcode.
選擇 Xcode > Open Developer Tool > Instruments.
Instruments啓動並且其圖標出現在您的Dock中
按住Control鍵並點按Dock中的Instruments圖標,然後從快捷菜單中選擇Options > Show in Finder
選擇show in Finder的時候會打開Instruments.app所在的文件夾,然後把Instruments.app拖到您的應用程序文件夾中
你在Launchpad就會看到這個Instruments這個app,這時候你不能直接打開。要刪除應用程序文件夾中的Instruments這個app,然後就可以打開了。
四、命令行打開
你可以使用命令行打開
方法如下:
打開 Terminal (in
/Applications/Utilities/
).運行下面的命令:
open /Applications/Xcode.app/Contents/Applications/Instruments.app