[ios] Can I safely delete contents of Xcode Derived data folder?

I am running low on disk space and checked through a third party utility that among other things that ~/Library/Developer/Xcode/DerivedData directory is taking about 22GB of disk space.

I searched stackoverflow and found this post

How can I safely delete in my ~/Library/Developer/Xcode/DerivedData directory?

The accepted answer to this question suggests that I should not touch / remove folders from this directory. so what I did was

  • Found an existing build project folder for an app that I have available on Appstore
  • Deleted the folder from derived dir
  • launched XCode 5
  • Open that project
  • Clean Build
  • Tested and compiled it on a simulator
  • ReArchived
  • Everything worked. Nothing was broken.

Unless I missed something in that posts answer I want to make sure by asking experienced developers that if I delete all the folders from DerivedData it will not hurt me in building, testing and compiling those projects.

This question is related to ios xcode

The answer is


I purge derivedData often enough that I have an alias for it. It can fix build problems. I have the following in /Users/Myusername/.bash_profile

alias purgeallbuilds='rm -rf ~/Library/Developer/Xcode/DerivedData/*'

Then in terminal, I type purgeallbuilds, and all subfolders of DerivedData are deleted.


yes, safe to delete, my script searches and nukes every instance it finds, easily modified to a local directory

#!/usr/bin/env bash
set -o errexit
set -o nounset
set -o pipefail
IFS=$'\n\t'

for drive in Swap Media OSX_10.11.6/$HOME
do
   pushd /Volumes/${drive}  &> /dev/null
   gfind . -depth -name 'DerivedData'|xargs -I '{}' /bin/rm -fR '{}'
   popd &> /dev/null
done

XCODE 10 UPDATE

Click to Xcode at the Status Bar Then Select Preferences

In the PopUp Window Choose Locations before the last Segment

You can reach Derived Data folder with small right icon

enter image description here


Just created a github repo with a small script, that creates a RAM disk. If you point your DerivedData folder to /Volumes/ramdisk, after ejecting disk all files will be gone.

It speeds up compiling, also eliminates this problem

xc-launch repo

Best launched using DTerm


XCODE 10 UPDATE

On the tab:

  1. Click Xcode
  2. Preferences
  3. Locations -> Derived Data

You can access all derived data and clear by deleting them.


 $ du -h -d=1 ~/Library/Developer/Xcode/*

shows at least two folders are huge:

 1.5G   /Users/horace/Library/Developer/Xcode/DerivedData
 9.4G   /Users/horace/Library/Developer/Xcode/iOS DeviceSupport

Feel free to remove stuff in the folders:

 rm -rf ~/Library/Developer/Xcode/DerivedData/*

and some in:

 open ~/Library/Developer/Xcode/iOS\ DeviceSupport/

~/Library/Developer/Xcode/DerivedData


I would say it's safe--I often delete the contents of the folder for many kind of iOS projects, this way. And, I haven't had any issues with builds or submitting to the App Store. The procedure deletes derived data and cleans a project's cached assets, for both Xcode 5 and 6.

Sometimes, simply calling rm -rf on the Derived Data directory leaves a lingering file or two, but my script loops until all files are deleted.


The content of 'Derived Data' is generated during Build-time. You can delete it safely. Follow below steps for deleting 'Derived Data' :

  1. Select Xcode -> Preferences..

Step 1

  1. This will open pop-up window. Select 'Locations' tab. In Locations sub-tab you can see 'Derived Data' Click on arrow icon next to path.

Step 2

  1. This will open-up folder containing 'Derived Data' Right click and Delete folder.

Step 3


I got this error because Int was int in one file. So stupid.


XCODE 7.2 UPDATE

(Also works for 7.1.1)

  1. Click Window then Projects and then delete Derived Data.

Like this:

enter image description here

And then delete it here:

enter image description here


Hope that helps!


XCode 8: To delete derived data for your current project:

Click Product menu

Hold Option key

Click Clean Build Folder


Examples related to ios

Adding a UISegmentedControl to UITableView Crop image to specified size and picture location Undefined Symbols error when integrating Apptentive iOS SDK via Cocoapods Keep placeholder text in UITextField on input in IOS Accessing AppDelegate from framework? Autoresize View When SubViews are Added Warp \ bend effect on a UIView? Speech input for visually impaired users without the need to tap the screen make UITableViewCell selectable only while editing Xcode 12, building for iOS Simulator, but linking in object file built for iOS, for architecture arm64

Examples related to xcode

Undefined Symbols error when integrating Apptentive iOS SDK via Cocoapods Xcode 12, building for iOS Simulator, but linking in object file built for iOS, for architecture arm64 iPhone is not available. Please reconnect the device Make a VStack fill the width of the screen in SwiftUI error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65 The iOS Simulator deployment targets is set to 7.0, but the range of supported deployment target version for this platform is 8.0 to 12.1 Xcode 10.2.1 Command PhaseScriptExecution failed with a nonzero exit code Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Xcode 10: A valid provisioning profile for this executable was not found Xcode 10, Command CodeSign failed with a nonzero exit code