0

I know that Xcode requires the simulator to launch while running a unit test. During my CI builds, I run unit tests. Sometimes the simulator hangs up the tests, and the tests complete once I dismiss the simulator.

Is there a way to test: 1. If we are in "test mode" in the app delegate 2. If we can programatically dismiss the simulator, either as soon as it appears or after x amount of time.

I wrote an AppleScript that will quit the simulator... I suppose I could launch it from Xcode. Does anyone know how to launch a script in a method?

Henry F
  • 4,960
  • 11
  • 55
  • 98
  • take a look at this http://stackoverflow.com/questions/355168/proper-way-to-exit-iphone-application – Alex Dec 29 '14 at 19:47
  • @Alex That appears to quit the app rather than the simulator – Henry F Dec 29 '14 at 19:50
  • 1
    If indeed you are trying to completely quit the simulator, your AppleScript method sounds fine to me – Alex Dec 29 '14 at 19:58
  • @Alex Thank you sir. Do you happen to know how to call upon the script in a method in my App? I dragged it into my project but am unsure of how to launch the script in a specific method... – Henry F Dec 29 '14 at 20:00

2 Answers2

1

iOS simulator is a mac app and cannot be dismissed from an iOS app.

either you do it with apple script or you can use a command in your build script to do that.

sudo killall "iOS Simulator"

edit: to clarify further, the script cannot be run from iOS app either. you have to call it from your build script.

Jeremy Huddleston Sequoia
  • 22,938
  • 5
  • 78
  • 86
Hashmat Khalil
  • 1,826
  • 1
  • 25
  • 49
1

Please file a bug report at http://bugreport.apple.com with information about what is causing the failure you are trying to workaround. Please take a sysdiagnose at the time and include ~/Library/Logs/CoreSimulator/*.log

As for programmatically running an AppleScript, you can do:

NSString *scriptSource = @"tell application ..."
NSAppleScript *script = [[[NSAppleScript alloc] initWithSource:scriptSource] autorelease];
NSError *error = nil;

[script executeAndReturnError:&error];

But you cannot use this from an app running within the iOS Simulator because it is isolated from the host.

Jeremy Huddleston Sequoia
  • 22,938
  • 5
  • 78
  • 86