aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorVikas Pachdha <vikas.pachdha@qt.io>2017-11-14 12:48:45 +0100
committerVikas Pachdha <vikas.pachdha@qt.io>2017-11-14 14:49:47 +0000
commit8c1a08d76093502125c391ac2b60929016cd2685 (patch)
tree51d9c4724d776d33af95beb52a9dd0ebef85cd1f /src
parent69e9f81bd8cf87b55867a6d782e7b80ccdc8e614 (diff)
iOS: Fix simulator startup for Xcode 9
For Xcode 9 boot the second device instead of creating a new simulator app instance Task-number: QTCREATORBUG-19270 Change-Id: I68d1c319f8b5e709fc20462098db0c89a66566eb Reviewed-by: Eike Ziller <eike.ziller@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/ios/simulatorcontrol.cpp31
1 files changed, 25 insertions, 6 deletions
diff --git a/src/plugins/ios/simulatorcontrol.cpp b/src/plugins/ios/simulatorcontrol.cpp
index 95c3ef00c5..e96bbfffe4 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<DeviceTypeInfo> getAvailableDeviceTypes()
{
QList<DeviceTypeInfo> deviceTypes;
@@ -421,12 +445,7 @@ void SimulatorControlPrivate::startSimulator(QFutureInterface<SimulatorControl::
}
if (simInfo.isShutdown()) {
- const QString cmd = IosConfigurations::developerPath()
- .appendPath("/Applications/Simulator.app/Contents/MacOS/Simulator")
- .toString();
- const QStringList args({"--args", "-CurrentDeviceUDID", simUdid});
-
- if (QProcess::startDetached(cmd, args)) {
+ if (launchSimulator(simUdid)) {
if (fi.isCanceled())
return;
// At this point the sim device exists, available and was not running.