File tree 3 files changed +20
-0
lines changed
3 files changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -28,6 +28,7 @@ interface IDevice {
28
28
29
29
interface ISimctl {
30
30
launch ( deviceId : string , applicationIdentifier : string ) : string ;
31
+ boot ( deviceId : string ) : void ;
31
32
terminate ( deviceId : string , appIdentifier : string ) : string ;
32
33
install ( deviceId : string , applicationPath : string ) : void ;
33
34
uninstall ( deviceId : string , applicationIdentifier : string , opts ?: any ) : void ;
Original file line number Diff line number Diff line change @@ -230,6 +230,12 @@ export class XCodeSimctlSimulator extends IPhoneSimulatorNameGetter implements I
230
230
this . killSimulator ( ) ;
231
231
}
232
232
233
+ // In case user closes simulator window but simulator app is still alive
234
+ if ( ! bootedDevice && this . isSimulatorAppRunning ( ) ) {
235
+ const defaultDevice = _ . find ( this . simctl . getDevices ( ) , device => device . name === this . defaultDeviceIdentifier ) ;
236
+ this . simctl . boot ( defaultDevice . id ) ;
237
+ }
238
+
233
239
common . startSimulator ( device . id ) ;
234
240
// startSimulaltor doesn't always finish immediately, and the subsequent
235
241
// install fails since the simulator is not running.
@@ -238,6 +244,15 @@ export class XCodeSimctlSimulator extends IPhoneSimulatorNameGetter implements I
238
244
}
239
245
}
240
246
247
+ private isSimulatorAppRunning ( ) {
248
+ try {
249
+ const output = childProcess . execSync ( "ps cax | grep -w Simulator" ) ;
250
+ return output . indexOf ( 'Simulator' ) !== - 1 ;
251
+ } catch ( e ) {
252
+ return false ;
253
+ }
254
+ }
255
+
241
256
private verifyDevice ( device : IDevice ) : void {
242
257
const availableDevices = this . getDevices ( ) ;
243
258
if ( ! _ . find ( availableDevices , { id : device . id } ) ) {
Original file line number Diff line number Diff line change @@ -28,6 +28,10 @@ export class Simctl implements ISimctl {
28
28
return result ;
29
29
}
30
30
31
+ public boot ( deviceId : string ) {
32
+ return this . simctlExec ( "boot" , [ deviceId ] ) ;
33
+ }
34
+
31
35
public terminate ( deviceId : string , appIdentifier : string ) : string {
32
36
return this . simctlExec ( "terminate" , [ deviceId , appIdentifier ] ) ;
33
37
}
You can’t perform that action at this time.
0 commit comments