从Xcode运行脚本阶段运行泄漏命令

时间:2020-07-28 20:25:26

标签: xcode memory-leaks xctest xcode-ui-testing

我想运行leaks命令并在我的构建文件夹中为编写了UI测试的iOS应用生成memgraph文件。基本应用取自以下YouTube上的UI测试教程:UI Testing iOS Tutorial

我正在尝试运行以下命令:

leaks UITestingTutorial --outputGraph=~/Desktop/leaks.memgraph

我尝试创建一个新的运行脚本阶段并添加命令:

这是我要添加运行脚本阶段的构建目标:

但是出现以下错误:

leaks[40014]: leaks cannot find any existing process you have access to which has a name like 'UITestingTutorial'; try running with `sudo`.
leaks[40014]: [fatal] mach port for process 0 not valid
Command PhaseScriptExecution failed with a nonzero exit code

我的上述脚本无法正常运行,因为该应用需要在模拟器中运行才能使泄漏命令起作用。我已经编写了此脚本来构建和启动应用程序,然后运行泄漏。可以在构建后使它运行,以便使内存图成为构建工件的一部分吗?我认为它仍然必须是一个运行阶段脚本。

xcrun xcodebuild \
-scheme UITestingTutorial \
-project UITestingTutorial.xcodeproj \
-configuration Debug \
-destination 'platform=iOS Simulator,name=iPhone 11,OS=13.6' \
-derivedDataPath \
build

open -a "Simulator"

# This simulator id has been manually found: 
# by running 'xcrun simctl list' and searching
# for iPhone 11 under iOS 13.6 under Devices 
# A script can be written to automatically find this
xcrun instruments -w 3100E7BC-0B95-4B3E-B0DC-8743FFCB731A
xcrun simctl install 3100E7BC-0B95-4B3E-B0DC-8743FFCB731A ./build/Build/Products/Debug-iphonesimulator/UITestingTutorial.app (http://uitestingtutorial.app/)
xcrun simctl launch 3100E7BC-0B95-4B3E-B0DC-8743FFCB731A com.codepro.UITestingTutorial
leaks UITestingTutorial —outputGraph=./leaks.memgraph

0 个答案:

没有答案