Xcode Storage Space Management

Hello everyone,

As I am progressing in my app development journey, I’ve come to realize that it really is eating away at my new mac air’s storage. I only have around 20 gigs left D:

I managed to shave away nearly 30 gbs from deleting from the Cache, Xcode/DerivedData and Xcode/ iOS DevideSupport folders.

However, the one that seems to be eating the most of my storage space is the: Xcode/UserData/Previews folder. It currently is eating 80GB of storage.

Is there anyway I can trim this? Are all the files in here necessary?

Download DevCleaner for Xcode! From the Mac App Store

It clears Xcode logs and old simulators. You can pick and choose which files to clear, but it’s a nice GUI, you can even set it up to do this on a weekly or monthly basis!

1 Like

Ah thank you! Will definitely look into it.
I’m guessing there’s nothing I can really do about that Previews folder though?

You could move the folder to another location and then re-open Xcode and see what happens. If it crashes then you know that the contents are important so you can move the folder back to where it was. If Xcode recreates the folder and there is less in it than there was then you know that it’s a temporary area that maybe you can cull from time to time.

Just a thought.

(edit).
DevCleaner has that folder as an option to clean out so that’s the tool to use.

That’s a good thought - I’ll try that right now.

I actually just tried using DevCleaner to try to clear out that file - but it wouldn’t delete it saying that I do not have permission to access it. Which seems silly, because I just tried moving the Previews folder to another location just fine. However, when i did move it, my Xcode worked, but the Previews were stuck indefinitely loading forever. New “Simulator Devices” folders weren’t being created either :frowning:

So I placed the files back where they belonged. Still hoping to find a way to trim this somehow as I’ve already cleaned out pretty much everything else I could possibly clean both manually and on DevCleaner. It’s just that Previews folder - and its also the heaviest.

I noticed the same thing with regard to permissions so decided to run Disk Utilities and selected First Aid. I’ll try DevCleaner again after I have done a backup,

1 Like

Thanks a bunch for your help Chris! Let me know when you can if you get the chance to try the DevCleaner again.

It would appear that running First Aid in DiskUtilties has not made any difference.

I still get a permissions error in DevCleaner. I’ve checked the permissions for each folder in the path to the “Previews” folder and it looks OK to me. I’ve even rebooted my Mac after the FirstAid run but the result is the same.

Looks to me like DevCleaner needs an update.

1 Like

Ah I see. Thanks for looking into that for me Chris! Here’s hoping they update before I truly run out of space :'D

You could try this: SwiftUI Previews - Disk space issue | Apple Developer Forums

Also you’d have to google it but there’s a good Ray Wenderlich tutorial for making a script to clean Xcode logs.

CWC also has a blog post somewhere