1

The simulator instance I'm using is sometimes left in an inconsistent state after a continuous integration run, how do I reset it?

It does not seem that resetting the simulator that runs in a normal user account on the build server will reset the simulator that is used by the Bots (which is run under the restricted _xcsbuild user.)

Community
  • 1
  • 1
Robert Atkins
  • 23,528
  • 15
  • 68
  • 97

1 Answers1

2

Inspired by this gist, run this script as a "Before Integration" trigger on your Bot:

/usr/bin/osascript -e 'tell application "iOS Simulator" to quit'
/usr/bin/osascript -e 'tell application "Simulator" to quit'
/usr/bin/xcrun simctl erase all

... and dupe radar 24091918 to add "all" as a valid argument to xcrun simctl shutdown.

Robert Atkins
  • 23,528
  • 15
  • 68
  • 97
  • 1
    Thanks for the suggestion regarding `simctl shutdown all`, however I don't think having that would be terribly helpful in your situation. You need to keep in mind that simctl is a client of CoreSimulator, just like Simulator.app is. simctl is not meant to control Simulator.app. – Jeremy Huddleston Sequoia Jan 08 '16 at 02:53
  • All I can say is, it seemed to work for me—resetting the simulator from a user account didn't work, doing the above as a trigger did. – Robert Atkins Jan 08 '16 at 09:19
  • Yes, the above will accomplish your goal, but I'm saying that you are misunderstanding the relationship between simctl and Simulator.app. If you are not using 'simctl boot', then there is no reason for you to use 'simctl shutdown' as the device is automatically shutdown when Simulator.app terminates. – Jeremy Huddleston Sequoia Jan 09 '16 at 17:40