kill iOS Simulator from terminal - terminal

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:
The problem is that the simulator doesn't get dismissed until an action on the prompt is taken. How to get rid of it?

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.

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)

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!

Please try
killall -9 "iPhone Simulator"

You can kill Simulator running from commandline.
killall "Simulator" || true

Related

Running "open -a Terminal.app MyScript", opens new terminal window, but doesn't run MyScript in it

I'm on mac, and need to open a new terminal window and run a script/compiled code in it.
Before "open -a Terminal.app Myscript" would work, but now it suddenly no longer runs the script.. only opens the Terminal Window.
If i just run the script, it works. Other scripts that worked before no longer work using open -a either.
I'm running Mojave 10.14.3 Beta. And bash 5.0.0, linked through Homebrew.
If anyone else can reproduce this, please do. I'm not sure if its a bug, or just a issue with me.
console reveals following error:
/usr/bin/open subsystem: com.apple.launchservices
"Unable to load Info.plist exceptions (eGPUOverrides)"
This error is triggered everytime the command is run.
I've also searched and haven't found anyone else experiencing this problem, nor alternatives to open -a.
It works again now. Not sure if it was due to a restart, or because of another program.

iOS simulator: double click home button does not work sometimes

With the iOS simulator version 10, double clicking the home button to bring up multitasking (running apps) sometimes does not respond. Even hitting (cmd + shift + h)x2 to simulate home button double click also works sometimes. I have verified this with a work mate and they have the same issue. I am not sure if this is a bug in the simulator or if there is a setting somewhere on for example the delay between the clicks? The answer from here did not make a difference.
I have this problem too when I want to close my app. So, I use command line instead:
xcrun simctl list | grep Booted
then copy simulator ID, and run this command to close app
xcrun simctl terminate <simulator ID> <your app bundle ID>
... or if you have only one simulator running, just type booted:
xcrun simctl terminate booted <your app bundle ID>
Enable this setting in the simulator hardware settings.
Hardware > Keyboard > Send Keyboard Shortcuts to Device
Command + Shift + H + H will no longer do anything BUT double tapping the home button on the simulator will start working as expected.

Why does my Xcode 8 GM have 50+ Simulator versions to choose from?

How can I fix this? I have 2.5 full pages of this:
Go into Window -> Devices. Then just select the Simulators you don't want and delete them (by hitting the Delete key, or right-clicking).
You can also un-select the "Show in Run Destinations Menu" item (when you right-click).
There was a bug in one of the earlier betas which could have caused extra devices to get created. The easiest thing to do is get back to a vanilla state. Quite Xcode.app, Simulator.app, etc and then run:
sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService
rm -rf ~/Library/*/CoreSimulator

How do I reset the simulator used by an Xcode bot?

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.)
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.

XCode using GUID instead of iOS version number in Simulator Selection

Somewhere during the various updates of XCode in the last month, the iOS versions dropped from my simulator selection (image below.) Anyone know how to resolve this?
How to fix it
Xcode uses the device version to disambiguate devices with the same name.
If two devices have the same name and version number, it will use the devices' UDIDs.
You have 4 of each of a bunch of devices (eg iPhone 5s). I suspect that some of them are for the same iOS version. You should delete some of the duplicates. Check out xcrun simctl list and xcrun simctl delete or use the device manager within Xcode.app (click on the "-" to delete a device).
How to just get back to a default state
# Ensure all possible clients of CoreSimulatorService are no longer running:
killall Xcode 2> /dev/null
killall Instruments 2> /dev/null
killall 'iOS Simulator' 2> /dev/null
killall Simulator 2> /dev/null
killall 'Simulator (Watch)' 2> /dev/null
killall ibtoold 2> /dev/null
killall simctl 2> /dev/null
# There may be others
# Kill the service itself
sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService
# Remove all the data and logs
rm -rf ~/Library/*/CoreSimulator
Why this might be happening:
CoreSimulatorService will monitor for the addition of new simulator runtimes in /Library/Developer/CoreSimulator/Profiles (eg, for when downloading them from Xcode -> Preferences -> Downloads). When installing a new runtime, CoreSimulatorService will create an initial set of devices for that runtime.
This problem arrises if there are multiple instances of CoreSimulatorService running at the same time. Each CoreSimulatorService instance will create its own set of devices (but its clients will only see that instances's sets at first). On subsequent launches (eg: after a reboot), both copies will be seen. One can get into a state where multiple copies of CoreSimulatorService are running at the same time due to testing beta versions of Xcode.app in the same login session as using the released Xcode.app or by having used Xcode.app before and after updating it through the App Store.
If you are aware of any other way that this bug might come about, please file a new radar at http://bugreport.apple.com
Deleting multiple copies of the same version from the Devices window did the trick for me.
I found this script to be the most efficient. I clears the list of existing simulators, than rebuilds it based on installed platforms.
See https://gist.github.com/cabeca/cbaacbeb6a1cc4683aa5

Resources