From 5b7adfe44aacbdb049d4e31c9f67e5f5fa6947e0 Mon Sep 17 00:00:00 2001 From: Nan Wang Date: Sun, 27 Aug 2023 16:20:04 -0700 Subject: [PATCH] no need to erase sims Signed-off-by: Nan Wang --- bp/src/BPSimulator.h | 1 - bp/src/BPSimulator.m | 53 -------------------------------------------- 2 files changed, 54 deletions(-) diff --git a/bp/src/BPSimulator.h b/bp/src/BPSimulator.h index 366b8205..c1f652c9 100644 --- a/bp/src/BPSimulator.h +++ b/bp/src/BPSimulator.h @@ -72,5 +72,4 @@ - (BOOL)needsRetry; - (BPExitStatus)exitStatus; - (BOOL)isApplicationLaunched; -- (BOOL)shutdownSimulatorWithError:(id *)error; @end diff --git a/bp/src/BPSimulator.m b/bp/src/BPSimulator.m index c77bb280..04c29ca8 100644 --- a/bp/src/BPSimulator.m +++ b/bp/src/BPSimulator.m @@ -127,7 +127,6 @@ - (NSString *)installApplicationWithHost:(NSString *)testHost withError:(NSError }]; return nil; } else { -// [simDevice shutdownWithError:errPtr]; [self shutdownSimulatorWithError:errPtr]; if(*errPtr) { [BPUtils printInfo:ERROR withString:@"Shutdown simulator failed with error: %@", [*errPtr localizedDescription]]; @@ -308,47 +307,6 @@ - (BOOL)useSimulatorWithDeviceUDID:(NSUUID *)deviceUDID { return YES; } -- (void)eraseSimulator:(SimDevice *)device withError:(id *) error{ - NSLog(@"Erasing Simulator %@", device.UDID.UUIDString); - [device eraseContentsAndSettingsWithError:error]; - if (*error) { - NSLog(@"Error erasing simulator: %@", *error); - } else { - NSLog(@"Simulator erased successfully."); - } -} - -- (BOOL)waitForSimulatorShutdown:(SimDevice *)device { - NSDate *startTime = [NSDate date]; - NSTimeInterval timeoutInterval = 30.0; - - while (![device.stateString isEqualToString:@"Shutdown"]) { - NSTimeInterval elapsedTime = -[startTime timeIntervalSinceNow]; - if (elapsedTime >= timeoutInterval) { - return NO; // Timeout - } - - // You might need to add some delay here to avoid busy-waiting - [NSThread sleepForTimeInterval:1.0]; - } - - return YES; // Successfully shutdown -} - -- (void)eraseAndShutdownSimulator:(SimDevice *)device withError: (id *)error { - // Wait for Shutdown - BOOL didShutdown = [self waitForSimulatorShutdown:device]; - - if (didShutdown) { - NSLog(@"Simulator has been successfully shutdown."); - } else { - NSLog(@"Failed to shutdown simulator within the timeout, erase it."); - // Erase Simulator - [self eraseSimulator:device withError:error]; - } -} - - - (BOOL)shutdownSimulatorWithError:(id *)error { [BPUtils printInfo:INFO withString:@"Starting Safe Shutdown of %@", self.device.UDID.UUIDString]; @@ -359,15 +317,6 @@ - (BOOL)shutdownSimulatorWithError:(id *)error { return YES; } - // Xcode 7 has a 'Creating' step that we should wait on before confirming the simulator is ready. - // On many occasions this is the case as we wait for the Simulator to be usable. - if ([self.device.stateString isEqualToString:@"Creating"]) { - [self eraseAndShutdownSimulator:self.device withError:error]; - return YES; - } - - // The error code for 'Unable to shutdown device in current state: Shutdown' - // can be safely ignored since these codes confirm that the simulator is already shutdown. return [self.device shutdownWithError:error]; } @@ -384,7 +333,6 @@ - (void)openSimulatorHeadlessWithCompletion:(void (^)(NSError *))completion { [self.device bootAsyncWithOptions:options completionHandler:^(NSError *bootError){ NSError *error = [self waitForDeviceReady]; if (error) { -// [self.device shutdownWithError:&error]; [self shutdownSimulatorWithError:&error]; if (error) { [BPUtils printInfo:ERROR withString:@"Shutting down Simulator failed: %@", [error localizedDescription]]; @@ -636,7 +584,6 @@ - (void)deleteSimulatorWithCompletion:(void (^)(NSError *error, BOOL success))co } if (self.device) { [BPUtils printInfo:INFO withString:@"Shutting down Simulator"]; -// [self.device shutdownWithError:&error]; [self shutdownSimulatorWithError:&error]; if (error) { [BPUtils printInfo:ERROR withString:@"Shutting down Simulator failed: %@", [error localizedDescription]];