Why one iOS Simulator couldn’t be deleted (and how I got rid of it)

The setup. My MacBook Air almost ran out of disk space, so I started deleting iOS Simulators. One of them, an iPhone 17, refused to go. Resetting it from Xcode’s UI and from xcrun simctl both failed the same way, and so did a reboot:

Failed to reset the device's content and settings.
"data" couldn't be moved because you don't have permission to access "Deleting-…".
Operation not permitted

How the simulator deletes a device? I figured out, it doesn’t remove the files where they are. It first moves the device’s data folder into a Deleting- folder in your temp directory, then deletes it from there. The move was what failed. Each attempt left another empty Deleting-* folder behind; I had about ten.

The cause: iCloud. Inside the simulator’s data folder, Library/Mobile Documents had an extended attribute:

com.apple.file-provider-domain-id = com.apple.CloudDocs.iCloudDriveFileProvider/

My Mac’s own ~/Library/Mobile Documents has the same attribute with a different UUID. Weeks earlier I had signed into my Apple Account inside that simulator to test iCloud features. Since then, the Mac had treated the simulator’s folder as a second, live copy of my iCloud Drive. My Desktop, Documents and backups were in there as cloud-only placeholders. The macOS won’t let anything move an active iCloud Drive folder, so the simulator’s delete step hit "Operation not permitted" every time. A reboot didn’t help because the folder is registered again at every login.

Don’t rm -rf it. Deleting it by hand is tempting, but while that folder is registered with iCloud, deleting its contents could be synced as deletions of your real iCloud Drive files.

The catch: "Unable to boot deleted device."

The obvious fix is to boot the simulator and sign out of iCloud. But the failed delete had already marked the device as deleted in its device.plist (isDeleted = true), so it wouldn’t boot. The fix:

D=~/Library/Developer/CoreSimulator/Devices/
cp "$D/device.plist" "$D/device.plist.bak"
plutil -replace isDeleted -bool NO "$D/device.plist"
killall -9 com.apple.CoreSimulator.CoreSimulatorService

The background service restarts on its own and reads the device as a normal one again. The rest is easy:

  1. Boot the simulator.
  2. Settings → your name → Sign Out. Don’t keep a copy of the data.
  3. Shut it down and delete it. This time it works.
  4. Delete the leftover empty Deleting-* folders in $TMPDIR.

Lessons

  • Use a test Apple Account in simulators, never your own. Signing in with your own puts your whole iCloud Drive into a folder you’ll eventually want to delete.
  • Before deleting a simulator you’ve signed into, sign out first.
  • If a delete fails with “Operation not permitted”, look for com.apple.file-provider-domain-id with xattr -l on the device’s data/Library/Mobile Documents.

Leave a Comment

Your email address will not be published. Required fields are marked *


Scroll to Top