diff --git a/detox/src/devices/common/drivers/ios/tools/AppleSimUtils.js b/detox/src/devices/common/drivers/ios/tools/AppleSimUtils.js index 5d952aed06..a5ac7a4753 100644 --- a/detox/src/devices/common/drivers/ios/tools/AppleSimUtils.js +++ b/detox/src/devices/common/drivers/ios/tools/AppleSimUtils.js @@ -59,7 +59,7 @@ class AppleSimUtils { await this._execSimctl({ cmd: `bootstatus ${udid}`, retries: 1 }); if (!headless) { - await this._openSimulatorApp(); + await this._openSimulatorApp(udid); } return true; @@ -79,8 +79,20 @@ class AppleSimUtils { return device; } - async _openSimulatorApp() { - await childProcess.execWithRetriesAndLogs(`open -a Simulator.app`, { retries: 0 }); + async _openSimulatorApp(udid) { + try { + await childProcess.execWithRetriesAndLogs(`open -a Simulator --args -CurrentDeviceUDID ${udid}`, { retries: 0 }); + } catch (err) { + this._logUnableToOpenSimulator(err); + } + } + + _logUnableToOpenSimulator(err) { + log.warn( + `Unable to open the Simulator app. If you are running tests from CI, consider running them with "--headless" ` + + `device configuration (see: https://wix.github.io/Detox/docs/next/api/configuration/#device-configurations).\n` + + `Error received: ${err.toString()}.` + ); } /***