Skip to content

Commit f8c10aa

Browse files
fix: launch default simulator rather than iPhone 6 (#126)
* fix for default simulator this fix let the XCode simulator choose the default simulator to run. Which is the last state of the simulator app. (can even be multiple simulators) Before that it was always choosing the same simulator. We now have the same behavior as the simulator app which brings a much better user experience ( imho) * chore: support no deviceId * Update iphone-simulator-common.ts * fix: don't check device state if it's null Co-authored-by: Igor Randjelovic <[email protected]>
1 parent 892c8ba commit f8c10aa

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

lib/iphone-simulator-common.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ export function getInstalledApplications(deviceId: string): IApplication[] {
4545

4646
export function startSimulator(deviceId: string): void {
4747
let simulatorPath = path.resolve(xcode.getPathFromXcodeSelect(), "Applications", "Simulator.app");
48-
let args = ["open", simulatorPath, '--args', '-CurrentDeviceUDID', deviceId];
48+
let args = ["open", simulatorPath];
49+
if (deviceId) {
50+
args.push( '--args', '-CurrentDeviceUDID', deviceId)
51+
}
4952
childProcess.execSync(args.join(" "));
5053
}
5154

lib/iphone-simulator-xcode-simctl.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -276,18 +276,16 @@ export class XCodeSimctlSimulator extends IPhoneSimulatorNameGetter implements I
276276
await this.verifyDevice(options.device);
277277
}
278278

279-
device = device || await this.getDeviceToRun(options);
280-
281279
// In case the id is undefined, skip verification - we'll start default simulator.
282280
if (device && device.id) {
283281
await this.verifyDevice(device);
284282
}
285283

286-
if (!device || !device.runtimeVersion || !device.fullId) {
287-
device = await this.getDeviceToRun(options, device);
284+
if (device && (!device.runtimeVersion || !device.fullId)) {
285+
device = null;
288286
}
289287

290-
if (!this.isDeviceBooted(device)) {
288+
if (!device || !this.isDeviceBooted(device)) {
291289
const isSimulatorAppRunning = this.isSimulatorAppRunning();
292290
const haveBootedDevices = this.haveBootedDevices();
293291

@@ -298,10 +296,10 @@ export class XCodeSimctlSimulator extends IPhoneSimulatorNameGetter implements I
298296
}
299297
this.simctl.boot(device.id);
300298
} else {
301-
common.startSimulator(device.id);
299+
common.startSimulator(device && device.id);
302300
}
303301

304-
common.startSimulator(device.id);
302+
common.startSimulator(device && device.id);
305303
// startSimulaltor doesn't always finish immediately, and the subsequent
306304
// install fails since the simulator is not running.
307305
// Give it some time to start before we attempt installing.

0 commit comments

Comments
 (0)