forked from qt-creator/qt-creator
iOS: Simplify starting simulator
We do not need different code paths for Xcode < 9 nowadays. Just tell simctl too boot the requested device and make sure the Simulator app is running. This also fixes an issue if for some reason a different device is already booted without the Simulator app running, e.g. 1. make sure Simulator is not running 2. boot a device from the command line with `xcrun simctl boot <deviceID>` (get the device ID from the Devices & Simulators window in Xcode) 3. start Qt Creator and run an application on a *different* simulator device Without this patch Simulator app opens with the device from (2) and deployment of the application fails for the different device. With this patch the device for (3) is booted and the application deployed and run. Change-Id: Ifce8c470f2d4d646295ca4e47fbd92308f87adf8 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -108,23 +108,16 @@ static expected_str<void> launchSimulator(const QString &simUdid, std::function<
|
|||||||
const FilePath simulatorAppPath = IosConfigurations::developerPath()
|
const FilePath simulatorAppPath = IosConfigurations::developerPath()
|
||||||
.pathAppended("Applications/Simulator.app/Contents/MacOS/Simulator");
|
.pathAppended("Applications/Simulator.app/Contents/MacOS/Simulator");
|
||||||
|
|
||||||
if (IosConfigurations::xcodeVersion() >= QVersionNumber(9)) {
|
// boot the requested simulator device
|
||||||
// For XCode 9 boot the second device instead of launching simulator app twice.
|
const expected_str<void> bootResult = runSimCtlCommand({"boot", simUdid}, nullptr, shouldStop);
|
||||||
QString psOutput;
|
if (!bootResult)
|
||||||
expected_str<void> result = runCommand({"ps", {"-A", "-o", "comm"}}, &psOutput, shouldStop);
|
return bootResult;
|
||||||
if (!result)
|
|
||||||
return result;
|
|
||||||
|
|
||||||
for (const QString &comm : psOutput.split('\n')) {
|
// open Simulator.app if not running yet
|
||||||
if (comm == simulatorAppPath.toString())
|
return runCommand(
|
||||||
return runSimCtlCommand({"boot", simUdid}, nullptr, shouldStop);
|
{"/usr/bin/open",
|
||||||
}
|
{IosConfigurations::developerPath().pathAppended("Applications/Simulator.app").nativePath()}},
|
||||||
}
|
nullptr);
|
||||||
const bool started = Process::startDetached(
|
|
||||||
{simulatorAppPath, {"--args", "-CurrentDeviceUDID", simUdid}});
|
|
||||||
if (!started)
|
|
||||||
return make_unexpected(Tr::tr("Failed to start simulator app."));
|
|
||||||
return {};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool isAvailable(const QJsonObject &object)
|
static bool isAvailable(const QJsonObject &object)
|
||||||
|
Reference in New Issue
Block a user