kill iOS Simulator from terminal
Asked Answered
V

6

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?

Venous answered 30/11, 2012 at 15:32 Comment(2)
why are you using SimulatorBridge instead of iPhone Simulator ?Raimondo
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.Venous
I
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)

Inflated answered 30/11, 2012 at 15:44 Comment(3)
on mavericks with xcode 6.1, I had to do killall "iOS Simulator". Thanks for the starting point :DInsurgency
On Xcode 8 killing the Simulator process is sometimes not enough. I also have to kill the process com.apple.CoreSimulator.CoreSimulatorService.Saluki
These answers look good for legacy but for 2019 xcode 10 I had to use https://mcmap.net/q/567724/-kill-ios-simulator-from-terminalBerti
C
46

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.

Calicle answered 25/1, 2019 at 6:18 Comment(6)
How this isn't the best answer is beyond me. +1 for simplicity!Haematite
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")Vinia
The solution that should popup as first result for any search of this question. +1Vulpecula
too bad sometimes it still leaves some com.apple.CoreSimulator.CoreSimulatorService running...Eltonelucidate
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.Calicle
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.Powerful
I
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)

Inflated answered 30/11, 2012 at 15:44 Comment(3)
on mavericks with xcode 6.1, I had to do killall "iOS Simulator". Thanks for the starting point :DInsurgency
On Xcode 8 killing the Simulator process is sometimes not enough. I also have to kill the process com.apple.CoreSimulator.CoreSimulatorService.Saluki
These answers look good for legacy but for 2019 xcode 10 I had to use https://mcmap.net/q/567724/-kill-ios-simulator-from-terminalBerti
C
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!

Carlyle answered 12/12, 2014 at 21:6 Comment(0)
R
3

Please try

killall -9 "iPhone Simulator"
Raimondo answered 30/11, 2012 at 15:46 Comment(0)
D
3

You can kill Simulator running from commandline.

killall "Simulator" || true

Diatonic answered 23/6, 2020 at 14:28 Comment(0)
H
0

On Sonoma 14.1 I seem to be getting a lot of orphaned core simulator processes.

This kills them all for me:

ps -ax | grep CoreSimulator | cut -d " " -f 1 | xargs sudo kill -9

Hereditable answered 15/5, 2024 at 0:40 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.