How to clean Xcode build files?

When I tried to use Xcode to compile an app for my iPhone, it also compiled a macOS version, but they don't work. I tried to delete them from the Applications folder, but they're not there. According to the Xcode logs, I found that they're located in /private/var/folders/ and there are some deprecated projects. How should I delete them?

Answered by DTS Engineer in 895347022

Hello @Tim222,

The easiest way you can do this is with Xcode itself.

Go to Product > Clean Build Folder or press CMD+Shift+K. This removes all those build products and intermediate files Xcode created for that project, including what's sitting in /private/var/folders/.

If its something simulator related, it might be helpful to use Terminal:

xcrun simctl delete unavailable

This is also useful because it deletes all simulator devices that are no longer available including deprecated projects that no longer have a matching runtime.

In my experience, I found better documentation for this in the man pages Apple ships inside Xcode.

You can read those by running these in Terminal:

  man xcodebuild
  xcrun simctl help delete

Thanks for your post!

 Travis

Hello @Tim222,

The easiest way you can do this is with Xcode itself.

Go to Product > Clean Build Folder or press CMD+Shift+K. This removes all those build products and intermediate files Xcode created for that project, including what's sitting in /private/var/folders/.

If its something simulator related, it might be helpful to use Terminal:

xcrun simctl delete unavailable

This is also useful because it deletes all simulator devices that are no longer available including deprecated projects that no longer have a matching runtime.

In my experience, I found better documentation for this in the man pages Apple ships inside Xcode.

You can read those by running these in Terminal:

  man xcodebuild
  xcrun simctl help delete

Thanks for your post!

 Travis

@DTS Engineer Hello,It worked, but some leftover builds of projects that have already been deleted still exist (searching in Apps for the deprecated projects still finds leftover builds, even though they can't be launched). Can I just use the rm command to delete everything inside /private/var/folders/?

I am sorry, it might be due to network issues or some other reason that the same content was submitted repeatedly.

How to clean Xcode build files?
 
 
Q