Search code examples
xcodeios-simulatorsimctl

simctl delete, Unable to delete device in current state: Creating


I am trying to delete a Simulator but it is in a state which simctl delete will not delete it. I removed it from all the places I can think, but a reference to it is preserved somewhere.

First, the listing:

    $ xcrun simctl list devices | grep 3B7
       Apple Watch - 38mm (3B7135C5-40A3-40FB-A130-12ACB448EE5D) (Creating) (unavailable, runtime profile not found)

Next, my delete attempt:

    $ xcrun simctl delete 3B7135C5-40A3-40FB-A130-12ACB448EE5D
    An error was encountered processing the command (domain=com.apple.CoreSimulator.SimError, code=159):
    Unable to delete device in current state: Creating

I next deleted the device directory, the entry from device_set.plist, and even the entry in .default_created.plist. Proof:

    $ pwd; ls -l 3*
    /Users/jeff/Library/Developer/CoreSimulator/Devices
    ls: 3*: No such file or directory
    $ grep 3B7 device_set.plist .default_created.plist ; echo Anything?
    Anything?

But that did not help. It was still there.

So without deleting the entire CoreSimulator/Devices folder, how do I remove this corrupt device entry?


Solution

  • You deleted it on disk, but CoreSimulatorService was running during that time and has no idea that you undermined its authority ;0.

    If you sudo killall -9 com.apple.CoreSimulator.CoreSimulatorService, it'll restart and not see it on the next launch.

    Also note that this particular bug was fixed in Xcode 8. You can now delete unavailable devices stuck in the creating state.