What is the Xcode Previews folder, and is it safe to delete?

The Xcode Previews folder holds simulator copies that Xcode creates to render SwiftUI previews, and it is safe to delete because Xcode makes new ones when a preview runs.

Shiva ChandraMaker of Clean House · · 2 min read
Short answer

The Xcode Previews folder holds the simulator copies Xcode makes to show SwiftUI previews in the canvas. It is safe to delete. Quit Xcode first, move the folder to the Trash, and Xcode rebuilds the preview devices the next time you open a preview, with a slower first run.

Path
~/Library/Developer/Xcode/UserData/Previews
What it is
Simulator devices Xcode creates for SwiftUI previews
Typical size
Often a few gigabytes; grows with the number of preview device types used
Made by
Xcode
Safe to delete?
Safe to clear
Comes back?
Yes, Xcode makes them again the next time a preview runs, which takes a little longer

What is in this folder?

SwiftUI previews run in a hidden simulator rather than on your regular devices. Xcode creates those preview simulators here, separate from the ones in CoreSimulator Devices that you see in the Simulator app. Each device type you preview on adds more files.

Nothing here is your design or code. Previews are drawn from your source files every time.

Is it safe to delete?

Yes. These are working copies for a feature Xcode can recreate. After deleting them, the first preview shows a longer loading state while Xcode builds a fresh preview device, and then it is back to normal.

Close Xcode first so it is not holding a preview device open. If the canvas stays stuck on "Failed to launch", clearing this folder is a common fix.

How do I clear it by hand?

  1. Quit Xcode and the Simulator app.
  2. Run the command below, or drag the folder to the Trash in Finder.
  3. Reopen your project and the canvas. Give the first preview a minute.
rm -rf ~/Library/Developer/Xcode/UserData/Previews
Quit Xcode first. Deleting preview devices while the canvas is rendering can leave it stuck until you restart Xcode.

How do I stop it growing?

There is no setting for it. Clear it when it gets large, or when previews stop loading.

How Clean House handles it

Clean House recognizes this folder as SwiftUI preview devices made by Xcode and rates it as rebuildable, with a note that previews take slightly longer the first time afterward. It goes to the Trash, so Recently Cleared can restore it.

Questions

Is it safe to delete the Xcode Previews folder?

Yes. Xcode recreates preview devices when a SwiftUI preview runs. Quit Xcode first.

Are preview simulators the same as the Simulator app devices?

No. Previews use their own hidden devices in this folder, separate from CoreSimulator Devices.

My SwiftUI preview will not load. Can this help?

Often, yes. Clearing the Previews folder with Xcode closed forces Xcode to build fresh preview devices.

Sources

  1. Apple Developer: Previews in Xcode
  2. Apple Developer: Xcode documentation