xcodecommand-lineios-simulatorxcrunsimctl

Is there a command to restart the Xcode iOS simulator from command line?


I have found a command to killall simulators but does not fit my needs. I need to be able to restart a particular simulator given the udid.

I have tried shutdown and then boot the simulator using

$ xcrun simctl shutdown <udid>
$ xcrun simctl boot <udid>
$ open -a simulator

but the simulator hangs after the execution of these commands.

Xcode version: 10.3 Simulator version: iPhone XS iOS: 12.4


Solution

  • I'm using xcode 11.3 but this seems to work for me:

    export UDID=$(xcrun simctl list devices | grep "(Booted)" | grep -E -o -i "([0-9a-f]{8}-([0-9a-f]{4}-){3}[0-9a-f]{12})")  
    xcrun simctl shutdown $UDID
    xcrun simctl boot $UDID
    

    Might be worth giving it an update to the latest xcode.