Clean Build Folder vs DerivedData removal for stale incremental artifacts
0 reputation · 19 Mar 2020, 20:06 UTC
0 reputation · 19 Mar 2020, 20:06 UTC
Choosing between Clean Build Folder and full DerivedData removal is a recurring decision when incremental builds appear to retain outdated artifacts.
Xcode stores build products, indexes and module caches under DerivedData. Clean Build Folder is documented as targeting the project's build products for the active scheme, while deleting DerivedData removes caches for all projects. The exact cache layers affected by each approach is version-sensitive, and it is unclear whether Clean Build Folder clears Clang or Swift module caches and index data, or whether DerivedData removal is scoped to a single project.
Which cache sublayers are cleared by Clean Build Folder in the installed Xcode version? Does full DerivedData removal affect only the selected project or all projects in ~/Library/Developer/Xcode/DerivedData? Under what documented conditions does each approach clear module and index caches?
34775 reputation · 20 Mar 2020, 06:46 UTC
Clean Build Folder targets the build products for the active scheme. It removes compiled object files and the final binary, but it typically leaves the module caches and index data intact. DerivedData removal is a destructive action that deletes all cached data, including indices and module caches, for every project stored in the default directory.
| Artifact Layer | Clean Build Folder | DerivedData Removal |
|---|---|---|
| Compiled Binaries / .o files | Cleared | Cleared |
| Swift/Clang Module Caches | Retained | Cleared |
| Project Indexing Data | Retained | Cleared |
| Build Logs | Retained | Cleared |
~/Library/Developer/Xcode/DerivedData) affects all projects managed by that Xcode instance.Product > Clean Build Folder (Cmd+Shift+K). This is the fastest way to resolve basic linking errors.~/Library/Developer/Xcode/DerivedData. This targets the specific project without wiping caches for all other projects.To verify the behavior in your current Xcode version, you can monitor the file system:
# Open the DerivedData folder in Terminal
cd ~/Library/Developer/Xcode/DerivedData
# List folders before cleaning
ls -R
# Perform 'Clean Build Folder' in Xcode, then check if the 'ModuleCache'
# or 'Index' directories were modified or deleted.
Diagnostic Detail Needed: Are you encountering specific "Module not found" errors or general linker failures? The former usually requires a module cache purge (DerivedData), while the latter is often solved by a simple Clean Build Folder.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.