是否可以使用终端在仪器中运行iOS应用程序?

时间:2013-06-27 11:08:22

标签: ios jenkins terminal xcode4.5

我想在Memory for Memory Leak中运行我的iPad应用程序并使用终端进行对象分配。

我也完成了goggling。我知道如何使用以下命令打开终端:

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>

我想从Jenkins运行仪器,这就是我在终端测试的原因。

我正在使用带有iOS 6.1.3的iPad 2。如果它也适用于模拟器,我很好。

如果我犯了任何错误,请指导我。

1 个答案:

答案 0 :(得分: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