3

我想使用终端在 Instrument for Memory Leak 和 object Allocation 中运行我的 iPad 应用程序。

我也做过护目镜。我知道如何使用以下命令打开终端:

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 运行 Instruments,这就是我在终端测试的原因。

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

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

4

1 回答 1

4

看起来您缺少特定的设备 ID ( [-w device])。尽管模板可能有它,但我认为您无论如何都需要在命令行中指定它。

我做了一些谷歌搜索并找到了这篇文章

这是基于该文章的配对脚本,您可以使用它从命令行运行 Instruments。

运行测试.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

来源:这里

于 2013-07-02T14:00:15.487 回答