22

I'm trying to terminate the iOS Simulator from the terminal console (needed for integrating automatic UI Testing in Jenkins),but every time I try the command:

killall SimulatorBridge

a prompt waiting for action gets displayed: enter image description here

The problem is that the simulator doesn't get dismissed until an action on the prompt is taken. How to get rid of it?

Claus
  • 5,662
  • 10
  • 77
  • 118
  • why are you using `SimulatorBridge` instead of `iPhone Simulator` ? – freedev Nov 30 '12 at 15:44
  • 1
    I simply didn't see any other actively related processes when I run ps on my terminal. I don't think it's a so stupid question to receive a down vote. – Claus Dec 01 '12 at 18:47

5 Answers5

45

The proper way to shutdown simulators is xcrun simctl shutdown all.

I don't recommend shutting down simulators by killing CoreSimulator.

Simulator.app is just a viewer (as of Xcode 9). It does not need to be launched and so does not need to be shut down either. It will respond to devices booting and shutting down automatically.

You can also hold down Option when quitting to detach from running simulators without shutting them down. Check the checkbox to make that the default behavior.

Similarly you can hold down Control when closing a window via File, Close to get a similar choice when closing a single simulator's window.

russbishop
  • 16,587
  • 7
  • 61
  • 74
  • 5
    How this isn't the best answer is beyond me. +1 for simplicity! – Michael Eakins Mar 07 '19 at 01:19
  • 1
    This should be the accepted answer in 2019... (FYI: if running Xamarin-based UITests or remote simulator, add `sudo` as processes are not owned by "you") – SushiHangover Apr 09 '19 at 07:19
  • The solution that should popup as first result for any search of this question. +1 – Maboo Apr 26 '20 at 13:10
  • too bad sometimes it still leaves some `com.apple.CoreSimulator.CoreSimulatorService` running... – minusf Nov 11 '20 at 08:42
  • Yes, CoreSimulatorService manages the database of simulators among other things. You shouldn't be killing it. The service restarts automatically when upgraded. You are likely to cause random problems by killing it. – russbishop Dec 15 '20 at 10:09
  • This should be the answer. I should have found this earlier, that would have saved me a ton of time and some embarassment. One of the scripts went berserk and launched a ton of simulator instances and no bash magic would work unless I just restarted my computer. – A. K. Jul 27 '21 at 01:04
37

Use killall "iPhone Simulator"

With XCode 6, use killall "iOS Simulator" (thanks @gempewsaw)

With XCode 7, use killall "Simulator" (thanks @Stanislaw)

With XCode 8, killing the Simulator process is sometimes not enough, also need to kill process com.apple.CoreSimulator.CoreSimulatorService (thanks @bensnider)

Slav
  • 27,057
  • 11
  • 80
  • 104
  • 3
    on mavericks with xcode 6.1, I had to do `killall "iOS Simulator"`. Thanks for the starting point :D – gempesaw Nov 21 '14 at 18:21
  • 7
    On Xcode 8 killing the Simulator process is sometimes not enough. I also have to kill the process `com.apple.CoreSimulator.CoreSimulatorService`. – bensnider Jul 13 '16 at 19:54
  • 2
    These answers look good for legacy but for 2019 xcode 10 I had to use https://stackoverflow.com/a/54359898/573180 – Charles Offenbacher Apr 12 '19 at 16:11
5

I agree with the answers above. Just wanted to add that I noticed my Jenkins job was failing when there was no simulator to kill. I got around this by adding it like this:

killall "iOS Simulator" || echo "No matching processes belonging to you were found"

Good luck with your ci!

Joe Susnick
  • 6,544
  • 5
  • 44
  • 50
3

Please try

killall -9 "iPhone Simulator"
freedev
  • 25,946
  • 8
  • 108
  • 125
2

You can kill Simulator running from commandline.

killall "Simulator" || true

Jijo John
  • 1,368
  • 2
  • 17
  • 31