5

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?

Jeff
  • 3,829
  • 1
  • 31
  • 49

1 Answers1

16

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.

Jeremy Huddleston Sequoia
  • 22,938
  • 5
  • 78
  • 86
  • So what I did was run `simctl delete` while **CoreSimulatorService** was running. And it is running even before I ever start my first Simulator from Xcode. And a reboot cleaned up the "Creating" mess. Killing the process as you suggested probably would have done it, too. – Jeff Sep 15 '16 at 15:23
  • CoreSimulatorService only starts if it is used (launching Xcode, Simulator, Instruments, xcodebuild, etc.). Launching Console.app on Sierra will also start it. – Jeremy Huddleston Sequoia Sep 18 '16 at 17:13
  • 1
    Thanks, Jeremy, great help! Maybe the bug was fixed in Xcode8 - but for sure, it was re-introduced for Xcode 9 ! (since in there, again, I cannot delete unavailable devices in the Creating state). With your great help, I was able to killall :) (....of course, being slightly incautious having deleted the simulator-device while compiling in the first place....) – iKK Mar 01 '18 at 10:12
  • Xcode 10 has the same issue. `CoreSimulatorService` will be started before `simctl delete`, so your method does not work for me. It's really annoying. – DawnSong Sep 18 '18 at 13:26
  • After restarting macOS, simulator profiles in the creating state disappeared automatically. – DawnSong Sep 18 '18 at 14:08