iOS: Cache xcrun location

runSimCtlCommand() is called quite often when the
user is in the settings. Trying to start a command without
a full path makes QtcProcess search for the file in all PATH
directories every time.

Change-Id: I7eac4226a74c78269ae66ab8d2a2af3589a98e36
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Marcus Tillmanns
2022-12-02 13:37:21 +01:00
parent b6bd59fc57
commit a9c1beed7a

View File

@@ -72,7 +72,11 @@ static bool runCommand(const CommandLine &command, QString *stdOutput, QString *
static bool runSimCtlCommand(QStringList args, QString *output, QString *allOutput = nullptr) static bool runSimCtlCommand(QStringList args, QString *output, QString *allOutput = nullptr)
{ {
args.prepend("simctl"); args.prepend("simctl");
return runCommand({"xcrun", args}, output, allOutput);
// Cache xcrun's path, as this function will be called often.
static FilePath xcrun = FilePath::fromString("xcrun").searchInPath();
QTC_ASSERT(!xcrun.isEmpty() && xcrun.isExecutableFile(), xcrun.clear(); return false);
return runCommand({xcrun, args}, output, allOutput);
} }
static bool launchSimulator(const QString &simUdid) { static bool launchSimulator(const QString &simUdid) {