Symptom: Xcode is using more disk space than expected, and a build or indexing task cannot continue.
Fastest safe fix: Xcode DerivedData cleanup is usually reasonable after you verify the active storage path. Remove only the project data you can identify, or clear the full DerivedData location if you accept that affected projects may need to rebuild. Keep Archives and their matching dSYMs separate.
Who this guide is for: Developers facing a full disk who are considering their first DerivedData cleanup.
Developers troubleshooting one project can use the scope checks to avoid clearing data for unrelated work.
Developers switching among projects, branches, or remote build environments can use the path and archive checks to protect their workflow.
00Start with the developer who needs a safe first cleanup
DerivedData is not your project’s source-code folder. Apple describes it as a location for generated data, including indexes, logs, and build products, and notes that Xcode can recreate generated files. Apple’s documented default location is ~/Library/Developer/Xcode/DerivedData; a custom setting can put the active data somewhere else. Check Apple’s description of generated files and the default Derived Data location before assuming that the default folder is the one consuming space.
The right action depends on what needs to change:
- If one project is the only concern, first try to identify and remove only its corresponding generated data.
- If several projects need a clean rebuild, clearing the verified DerivedData location may be appropriate, but expect affected projects to regenerate files.
- If the directory is not the main source of disk use, stop there. Deleting it will not address unrelated storage pressure.
- If the files are in a custom location, inspect that location instead of deleting the default folder out of habit.
The important distinction is between generated data you can rebuild and release records you may need to retain. A cleanup can remove the former; it should not become a general deletion of everything associated with Xcode.
01Confirm the path before choosing the cleanup scope
Start in Xcode’s Locations settings and check the active Derived Data location. Apple documents both the default and the option to configure a different location. If the path is customized, note it exactly, then inspect that directory in Finder. Do not treat the default path as authoritative when the active setting points elsewhere.
A second check is useful when builds come from different projects or workspaces. Xcode workspaces can organize related projects and dependencies, but that does not establish a universal one-to-one mapping between each workspace and a folder you can safely delete. Apple’s workspace documentation explains how projects and dependencies are organized. Use the actual path and files in your environment; do not infer ownership from a folder name that only looks familiar.
For a read-only size check in Terminal, substitute the verified path for /path/to/DerivedData:
du -sh "/path/to/DerivedData"
This reports the size of the specified location; it does not remove files. To inspect individual entries, use Finder or a read-only listing command, then compare what you find with the projects and workspaces you actually build. If the contents cannot be mapped confidently, do not guess and delete.
02Choose an Xcode DerivedData cleanup scope
Use these decision branches before removing anything:
- If one project is affected and its generated-data folder is clearly identifiable, remove only that project’s generated data. Otherwise, stop and verify the mapping before acting.
- If several projects are affected and rebuilding them is acceptable, consider clearing the full, verified DerivedData location. Expect more than one project to regenerate indexes or build products.
- If the active path is custom or belongs to a shared workflow, confirm who uses it and which build process writes there before cleanup.
- If the goal is to recover release or debugging records, do not treat DerivedData as the target. Check Archives and dSYMs separately.
- If the disk remains nearly full after a scoped cleanup, investigate other storage sources rather than repeating the same deletion.
A project-level cleanup is the narrower choice only when the target data is identifiable. Do not assume that a directory’s apparent project name guarantees it contains only disposable data for that project. If identification is uncertain, a full cleanup may be simpler, but it also expands the rebuild impact. Choose it only when you have accounted for the other projects that use that location.
For projects with custom build setups, build settings can affect where products and intermediate data are placed. Apple’s build settings reference is useful when the visible folder structure does not match expectations. Configuration files can also define build settings; Apple documents how to add a build configuration file. Use those sources to investigate the project’s actual configuration, not to assume that every project follows the same layout.
03Clean one project without turning it into a workspace-wide reset
If only one project is showing a problem, use a narrow, evidence-based process:
- Record the current state. Note the project or workspace, the Xcode setup used to build it, and the Derived Data path shown in Locations settings.
- Inspect the target directory. Check its contents in Finder and confirm that the data you plan to remove maps to the intended project. A name that resembles a project is a clue, not proof.
- Close Xcode before removal. This avoids acting while the application may still be reading or writing generated data.
- Move only the verified target to Trash. Do not empty the Trash immediately if you are unsure whether the selection was correct. Confirm the project still opens and the required files are intact first.
- Reopen the project and test the specific task. Check whether indexing recovers and whether the project can build. Treat the result as a project-level verification, not proof that deletion fixes every Xcode issue.
When a folder cannot be tied to one project with confidence, do not improvise a selective deletion. You can first create a controlled test using a known project-specific build location, then check whether the build behaves as expected before removing old data. Keep changes to build settings reversible, and record the prior value before changing it.
Deleting DerivedData does not delete source code when the selected location is genuinely DerivedData. The practical risk is selecting the wrong path or removing generated files used by other work. This is why path verification matters more than whether the cleanup is described as “safe” in general.
04Check the rebuild cost before clearing data for several projects
A full cleanup may remove indexes and build products for multiple projects that use the same location. Xcode can regenerate generated files, but the next build and indexing session may need to do that work again. The time and impact depend on the project, the build configuration, and whether dependencies are already available. Do not plan around a fixed recovery time.
Before choosing a wider cleanup, check:
- Can each affected project still access its source files and required project configuration?
- Are dependencies available locally, or might a build need to fetch them again?
- Is the build location shared by projects or workspaces that are not part of the current problem?
- Can the project complete a clean build after the proposed cleanup?
- Will a full cleanup interrupt another build or a release task?
If the immediate goal is to fix one failed build, preserve the original error and test the project after a scoped cleanup. A successful rebuild shows that the project can rebuild with its current environment; it does not prove that DerivedData caused the original failure. If the same error returns, investigate the build configuration, dependency state, or the underlying error rather than repeatedly deleting generated files.
After a cleanup, compare the available disk space with the amount you observed before it. This verifies whether the targeted location was a meaningful contributor. If space barely changes, look elsewhere. If it changes and then falls again during normal work, track which projects and build workflows are writing data before scheduling another cleanup.
05Keep Archives and dSYMs outside the cleanup decision
DerivedData and Xcode Archives serve different purposes. Generated build data can be recreated; an archive may be part of the record for a distributed build. Apple’s release guidance covers distributing builds for testing and release, and its debugging documentation explains the role of symbols in diagnosing crashes. Review Apple’s distribution guidance and the documentation on including debugging information before changing release records.
Do not expand a DerivedData cleanup into deleting every folder with “Xcode” in its name. In particular:
- Keep Archives you still need for release history, validation, or follow-up work.
- Keep the matching dSYM files needed to symbolicate crash reports for distributed builds.
- If a symbol file appears to be missing, check Apple’s guidance on locating a missing debug symbol file before rebuilding or deleting other records.
- Separate cache maintenance from release-retention decisions. Decide what to retain based on the builds you have distributed and the debugging records you may need.
A useful post-cleanup check is to confirm that the intended archive remains available and that its associated debugging symbols have not been removed. The point is not to preserve every generated file forever; it is to avoid losing material that cannot be recreated from the current build environment in the form you need.
06FAQ: Check the cases that change the decision
Will removing DerivedData delete my source code?
No, not when the selected location is genuinely DerivedData. It contains generated data, not the source files in your project folder. The risk is choosing the wrong path or an ambiguous directory. Confirm the active location in Xcode, inspect the target before removing it, and avoid deleting folders merely because their names contain “Xcode” or resemble a project.
How can I clear data for just one Xcode project?
Confirm the active Derived Data location, then identify the exact generated data for the project before removing it. Do not rely on a folder name alone, especially when a workspace contains related projects. If you cannot establish the mapping, pause rather than guessing. A scoped cleanup is only safer when the selected files are actually limited to the project you intend to reset.
Where do I check a custom DerivedData location?
Open Xcode’s Locations settings and check the Derived Data path. The default folder is not necessarily active if someone changed the setting. If different Xcode setups or workspaces are involved, verify the setting in the environment that produced the files. Then inspect that location; deleting the default directory will not clear data stored elsewhere.
Why can the first build take longer after cleanup?
The next build may need to recreate removed build products, and Xcode may need to rebuild indexes. Dependency availability and project configuration also affect what happens, so do not assume a fixed delay. Confirm whether dependencies need to be fetched, run the relevant build, and check whether indexing returns. If the original error persists, investigate it directly instead of repeating the cleanup.
07Decide whether the local Mac still fits the build workload
If a verified cleanup does not resolve recurring disk pressure, compare the current workflow with moving some builds to a separate Mac environment. A local Mac keeps the project and build process close at hand, but its internal storage remains a shared constraint; maintaining a spare machine also means managing another system. A remote Mac can separate build work from a developer’s local disk, but it still needs its own storage management, and it is not a substitute for preserving Archives or confirming that a project builds correctly.
For a workflow that needs a continuously available macOS build environment, assess the project’s dependencies, signing process, data-handling requirements, and expected workload before changing machines. The NUKCLOUD remote Mac overview explains the service context, while the Hong Kong order details can be checked for the terms shown on that page. If the build is occasional, local cleanup or an existing Mac may be enough; if disk pressure repeatedly interrupts builds, compare the cost and operational fit of moving that workload before deciding.