diff --git a/src/plugins/ios/simulatorcontrol.cpp b/src/plugins/ios/simulatorcontrol.cpp index 95c3ef00c5b..e96bbfffe4b 100644 --- a/src/plugins/ios/simulatorcontrol.cpp +++ b/src/plugins/ios/simulatorcontrol.cpp @@ -93,6 +93,30 @@ static bool runSimCtlCommand(QStringList args, QByteArray *output) return runCommand("xcrun", args, output); } +static bool launchSimulator(const QString &simUdid) { + QTC_ASSERT(!simUdid.isEmpty(), return false); + const QString simulatorAppPath = IosConfigurations::developerPath() + .appendPath("Applications/Simulator.app/Contents/MacOS/Simulator").toString(); + + if (IosConfigurations::xcodeVersion() >= QVersionNumber(9)) { + // For XCode 9 boot the second device instead of launching simulator app twice. + QByteArray psOutput; + if (runCommand("ps", {"-A", "-o", "comm"}, &psOutput)) { + QByteArray simulatorCommand = simulatorAppPath.toLatin1(); + for (const QByteArray &comm : psOutput.split('\n')) { + if (comm == simulatorCommand) + return runSimCtlCommand(QStringList({"boot", simUdid}), nullptr); + } + } else { + qCDebug(simulatorLog) << "Can not start Simulator device." + << "Error probing Simulator.app instance"; + return false; + } + } + + return QProcess::startDetached(simulatorAppPath, {"--args", "-CurrentDeviceUDID", simUdid}); +} + static QList getAvailableDeviceTypes() { QList deviceTypes; @@ -421,12 +445,7 @@ void SimulatorControlPrivate::startSimulator(QFutureInterface