Fix: Clear iPhone Simulator Cache Quickly with xcrun simctl in Xcode

Fix: Clear iPhone Simulator Cache Quickly with xcrun simctl in Xcode

Written by

in

Quick answer: Run xcrun simctl erase all in Terminal to wipe every simulator instantly. For a single device, use xcrun simctl erase <device-id>. Alternatively, use Simulator ▸ Reset Content and Settings… or assign a custom keyboard shortcut for one-key resets.

Why this happens

The iOS Simulator stores app containers, user defaults, keychain items, and derived data in per-device directories under ~/Library/Developer/CoreSimulator/Devices/. Xcode’s Clean Build Folder (⇧⌘K) only removes build intermediates in DerivedData; it never touches the simulator runtimes. When you change bundle identifiers, modify Core Data models, test first-launch flows, or debug push-notification permissions, stale simulator state causes misleading crashes, missing files, or permission prompts that no longer appear. Manually deleting folders in Finder is slow, error-prone, and risks removing the wrong device.

How to fix it

1. Nuclear option: erase every simulator at once (fastest)

Quit the Simulator app, open Terminal, and run:

xcrun simctl erase all

This command deletes all device data—apps, settings, keychains, and logs—for every simulator runtime installed. It is safe, idempotent, and completes in seconds. Use it when you want a completely clean slate across iOS, watchOS, and tvOS simulators.

2. Target a single device

If you only need to reset one simulator, list available devices first:

xcrun simctl list devices

Copy the UDID of the desired device (e.g., 3A1B2C4D-5E6F-7A8B-9C0D-1E2F3A4B5C6D) and run:

xcrun simctl erase 3A1B2C4D-5E6F-7A8B-9C0D-1E2F3A4B5C6D

You can also use the device name if it’s unique:

xcrun simctl erase "iPhone 16 Pro"

3. GUI method: Simulator menu

With the Simulator running, choose Device ▸ Erase All Content and Settings… (or Simulator ▸ Reset Content and Settings… on older macOS versions). Confirm the dialog. This is discoverable and requires no Terminal, but must be repeated for each device.

4. One-keystroke reset via custom keyboard shortcut

For frequent resets, assign a global shortcut:

  1. Open System Settings ▸ Keyboard ▸ Keyboard Shortcuts… ▸ App Shortcuts.
  2. Click +, choose Simulator (or Other… and navigate to Xcode.app/Contents/Developer/Applications/Simulator.app).
  3. Enter the exact menu title: Erase All Content and Settings… (including the ellipsis character ⌥;).
  4. Press your preferred key combo (e.g., ⌘⇧⌫).
  5. Click Done.

Now pressing that shortcut while Simulator is frontmost triggers an instant reset.

How to prevent it

  • Add xcrun simctl erase all as a Run Script build phase (set to run before compilation) in debug configurations to start every session clean.
  • Use scheme pre-actions (Edit Scheme ▸ Build ▸ Pre-actions ▸ + ▸ New Run Script Action) with the same command so it runs before every launch without polluting the project file.
  • Keep simulator runtimes updated via Xcode ▸ Settings ▸ Platforms to avoid stale runtime bugs that masquerade as cache issues.
  • Prefer SwiftUI previews or unit tests for logic that doesn’t require a full app launch; they bypass simulator state entirely.

FAQ

Does xcrun simctl erase all delete my Xcode projects or DerivedData?

No. It only removes the simulator device directories under ~/Library/Developer/CoreSimulator/Devices/. Your source code, build folder, and Xcode preferences remain untouched.

Can I run the erase command while the Simulator is open?

It’s safer to quit Simulator first. If a device is booted, simctl will shut it down automatically, but open windows may show transient errors.

Will this fix “Could not find iPhone X simulator” errors?

No. That error usually means the simulator runtime is missing or the device definition is corrupted. Use Xcode ▸ Settings ▸ Platforms to download the required runtime, or run xcrun simctl delete unavailable to purge broken device entries.

Is there a way to erase only the app container, not the whole device?

Yes. With the device booted, run xcrun simctl terminate booted <bundle-id> then xcrun simctl uninstall booted <bundle-id>. This removes just that app’s sandbox while preserving OS settings and other apps.

Does the keyboard shortcut work on macOS Sonoma and later?

Yes. The App Shortcuts pane in System Settings works identically on macOS 14+. Ensure you type the menu title exactly as it appears, including the true ellipsis character (⌥;).

Sources & credits

Parts of this guide are adapted from content licensed under CC BY-SA 4.0; this article is shared under the same license.