2013-06-27 49 views
3

我想在儀器中使用終端運行我的iPad應用程序內存泄漏和對象分配。是否可以使用終端在儀器中運行iOS應用程序?

我已經做了goggling作爲well.I知道如何使用下列命令打開終端:

open /Developer/Applications/Instruments.app

我曾嘗試下面的命令也是如此。

instruments -t "/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/Resources/templates/Leaks.tracetemplate" -/Users/iOSRider/Downloads/samplecode/build/Release-iphoneos/sample.app 

,但我得到以下錯誤:

`-[NSAlert alertWithError:] called with `nil NSError. 

一般性錯誤信息將被顯示,但用戶值得更好。

然後我試圖

instruments -w "cd73f2aadff0726a923b22bc69fdca4420f08ffb" -t "/Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/Resources/templates/Leaks.tracetemplate" -/Users/iOSRider/Downloads/samplecode/build/Release-iphoneos sample.app 

,但我得到以下錯誤:

Instruments Trace Error : Failed to start trace. 

我曾嘗試下面的命令,以及

instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate /Users/iOSRider/Library/Developer/Xcode/DerivedData/sample-ejuawqyrosinegcnvzhyrjhxkyue/Build/Products/Debug-iphonesimulator/sample.app 

,但我得到新的錯誤現在

Instruments Trace Error : Failed to start trace. 
iOSTeam:~ iOSRider$ 
iOSTeam:~ iOSRider$ instruments -t /Applications/Xcode.app/Contents/Applications/Instruments.app/Contents/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate /Users/iOSRider/Library/Developer/Xcode/DerivedData/sample-ejuawqyrosinegcnvzhyrjhxkyue/Build/Products/Debug-iphonesimulator/sample.app 
2013-06-27 17:02:44.103 instruments[15986:1603] -[NSAlert alertWithError:] called with nil NSError. A generic error message will be displayed, but the user deserves better. 


2013-06-27 17:09:03.530 instruments[15986:7877] Connection peer refused channel request for "com.apple.instruments.server.services.processcontrol"; channel canceled <DTXChannel: 0x7fde6dbc2390> 
2013-06-27 17:09:03.530 instruments[15986:7877] Connection peer refused channel request for "com.apple.instruments.server.services.capabilities"; channel canceled <DTXChannel: 0x7fde6db89130> 
2013-06-27 17:09:03.530 instruments[15986:7877] Connection peer refused channel request for "com.apple.instruments.server.services.processcontrol.posixspawn"; channel canceled <DTXChannel: 0x7fde6dbc2a50> 
2013-06-27 17:09:03.531 instruments[15986:7877] Connection peer refused channel request for "com.apple.instruments.server.services.filebrowser"; channel canceled <DTXChannel: 0x7fde6dbb8da0> 
2013-06-27 17:09:03.531 instruments[15986:7877] Connection peer refused channel request for "com.apple.instruments.server.services.deviceinfo"; channel canceled <DTXChannel: 0x7fde6db8ead0> 
2013-06-27 17:09:03.531 instruments[15986:7877] Connection peer refused channel request for "com.apple.instruments.server.services.launchdaemon"; channel canceled <DTXChannel: 0x7fde6dbc3740> 
2013-06-27 17:09:03.532 instruments[15986:7877] Connection peer refused channel request for "com.apple.instruments.server.services.wireless"; channel canceled <DTXChannel: 0x7fde6dbbcfb0> 
2013-06-27 17:09:03.532 instruments[15986:7877] Connection peer refused channel request for "com.apple.instruments.server.services.mobilenotifications"; channel canceled <DTXChannel: 0x7fde6dbbe050> 

我想從詹金斯運行儀器,這就是爲什麼我在終端測試。

我在iOS 6.1.3上使用iPad 2。我很好,如果它也可以在模擬器中使用。

如果我犯了什麼錯誤,請指導我。

回答

4

看起來你缺少一個特定的設備ID([-w device])。雖然模板可能有它,但我認爲你需要在命令行指定它。

我做了一些谷歌搜索,發現this article

下面是一個基於該文章的配對下來的腳本,您可以使用它從命令行運行Instruments。

runTests.sh

XCODE_PATH=`xcode-select -print-path` 
TRACETEMPLATE="$XCODE_PATH/Platforms/iPhoneOS.platform/Developer/Library/Instruments/PlugIns/AutomationInstrument.bundle/Contents/Resources/Automation.tracetemplate" 
APP_LOCATION=$2 
DEVICE_ID=$3 

if [ ! $# -gt 1 ]; then 
    echo "You must specify the app location and the test file." 
    echo "\t (optionally supply unique device ID of physical iOS device)" 
    echo "\t eg. ./build.sh suite.js <xcodeproject directory>/build/Debug-iphonesimulator/myapp.app <device-udid>" 
    exit -1 
fi 

# If running on device, only need name of app, full path not important 
if [ ! "$DEVICE_ID" = "" ]; then 
    RUN_ON_SPECIFIC_DEVICE_OPTION="-w $DEVICE_ID" 
    APP_LOCATION=`basename $APP_LOCATION` 
fi 

# Kick off the instruments build 
instruments \ 
$RUN_ON_SPECIFIC_DEVICE_OPTION \ 
-t $TRACETEMPLATE \ 
$APP_LOCATION \ 
-e UIARESULTSPATH /var/tmp 

來源:here

+0

它只有在Simulator.Is工作有任何機會進行檢測內存泄漏直接在設備? –

相關問題