Skip to content

Commit 3bd2f4d

Browse files
Fix restarting of application on simulator with OS < 10
In case the OS version of the simulated device is below 10, (for example 8.4) the `simctl terminate` does not kill the app immediately, so we kill it after we've called start. Fix this by waiting 500 ms.
1 parent c0f761b commit 3bd2f4d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

lib/iphone-simulator-xcode-simctl.ts

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -97,16 +97,20 @@ export class XCodeSimctlSimulator extends IPhoneSimulatorNameGetter implements I
9797
// Ignore the error.
9898
}
9999

100+
let resultOfTermination: string;
100101
if (xcodeMajorVersion && xcodeMajorVersion < 8) {
101102
// Xcode 7.x does not have support for `xcrun simctl terminate` command
102-
const resultOfKill = childProcess.execSync(`killall ${bundleExecutable}`, { skipError: true });
103-
// killall command does not terminate the processes immediately and we have to wait a little bit,
104-
// just to ensure all related processes and services are dead.
105-
utils.sleep(0.5);
106-
return resultOfKill;
103+
resultOfTermination = childProcess.execSync(`killall ${bundleExecutable}`, { skipError: true });
107104
} else {
108-
return this.simctl.terminate(deviceId, appIdentifier);
105+
resultOfTermination = this.simctl.terminate(deviceId, appIdentifier);
109106
}
107+
108+
// killall command does not terminate the processes immediately and we have to wait a little bit,
109+
// just to ensure all related processes and services are dead.
110+
// Same is valid for simctl terminate when Simulator's OS version is below 10.
111+
utils.sleep(0.5);
112+
113+
return resultOfTermination;
110114
} catch (e) {
111115
}
112116
}

0 commit comments

Comments
 (0)