Post

Resetting the Xcode Preview for a Clean Environment

Fix SwiftUI preview glitches by resetting Xcode's hidden simulator environment.

Resetting the Xcode Preview for a Clean Environment

When working with SwiftUI previews, Xcode occasionally misbehaves—showing stale views, outdated data, or even refusing to render your preview entirely. This usually happens because previews are powered by a hidden simulator environment that can retain state across builds.

The good news? You can easily reset this preview system using a command Apple introduced in Xcode 15:

📼 Reset SwiftUI Previews

To wipe the preview simulator and start fresh, run the following command in your terminal:

1
xcrun simctl --set previews delete all

This command deletes all preview-specific simulators created and cached by Xcode. It’s safe, fast, and often resolves the “Preview not updating” or “Stuck loading” issues.

💡 You don’t need to restart Xcode afterward, but rebuilding your preview (⌘ + Option + P) is a good idea.

🛠️ When Should You Use This?

  • Previews are stuck or crash every time
  • Data doesn’t reflect your latest changes
  • Environment variables or devices aren’t behaving as expected
  • You’ve updated Core Data, SwiftData, or iCloud settings in your app

🔁 Automate it (Optional)

If you run into this often, create a shortcut or alias in your shell config:

1
alias resetPreviews='xcrun simctl --set previews delete all'

Then just type resetPreviews whenever you want a clean slate.


SwiftUI previews are powerful but can occasionally get messy behind the scenes. Now you know how to give them a quick refresh.

Happy previewing!

☕ Support My Work

If you found this post helpful and want to support more content like this, you can buy me a coffee!

Your support helps me continue creating useful articles and tips for fellow developers. Thank you! 🙏

This post is licensed under CC BY 4.0 by the author.