How to recover from deleting Xcode CoreSimulator devices from disk?

By mistake I deleted ~/Library/Developer/CoreSimulator/Devices from my Mac so all my Xcode simulators were deleted.

Now none of my Xcode projects run. When I try to, an alert shows that no simulator is selected in select device.


Solution 1:

To get back to a vanilla state, quit Xcode, Simulator, Instruments, and any other CoreSimulator clients that you have and run:

sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService 2> /dev/null
rm -rf ~/Library/*/CoreSimulator

Solution 2:

You can add new simulators inside the Xcode. Simply press ⌘ CMD+⇧ SHIFT+2 to open Devices window. There on the lower left side you have small "+".

enter image description here