Xcode Eating
iCloud Storage?
If you are an Apple developer with Desktop & Documents sync enabled, Xcode is silently uploading gigabytes of build artifacts, archives, and caches to iCloud. DerivedData alone can be 5-15 GB. Combined with .xcarchive files and Swift Package caches, developers routinely lose 10-30 GB of iCloud storage to Xcode junk.
Why Xcode files end up in iCloud
macOS has a feature called Desktop & Documents sync. When it is enabled, every file in ~/Desktop and ~/Documents gets uploaded to iCloud Drive. Apple designed this for regular users who save a few Word documents and PDFs. It was not built for developers.
If you keep your Xcode projects on your Desktop or in Documents (or in any subfolder of those locations), the entire project directory gets synced. That includes:
- DerivedData — Xcode's build cache. Grows to 500 MB-5 GB per project. Contains compiled object files, indexes, and build logs that are completely disposable.
- .xcarchive files — App archives created when you build for distribution. Each one is 200 MB-1 GB depending on your app size.
- Swift Package Manager caches — SPM downloads and caches every dependency. For a project with 20-30 packages, this can be 500 MB-2 GB.
- .git directories — Your entire git history. For a project with a long history and binary assets, the .git folder alone can be several GB.
- Build folders — Output from builds, including debug and release binaries.
Apple does not exclude any of these automatically. There is no built-in "ignore developer files" option. If it is in Desktop or Documents, it syncs. Period.
Xcode DerivedData eating iCloud space
DerivedData is the biggest offender. Xcode stores build caches in ~/Library/Developer/Xcode/DerivedData/ by default, which is not in iCloud. But many developers change the DerivedData location to be inside their project folder, or they use Xcode workspaces that generate DerivedData in the project directory.
Even if your DerivedData is in the default Library location, if your project itself is on the Desktop, every other build artifact inside the project folder syncs to iCloud.
To delete DerivedData and free local space:
rm -rf ~/Library/Developer/Xcode/DerivedData
This is safe. Xcode rebuilds DerivedData the next time you open a project and build. You lose nothing except the cache.
To see how much space DerivedData is using:
du -sh ~/Library/Developer/Xcode/DerivedData
Do not be surprised if it is 10-20 GB. For details on managing Xcode storage, see Apple's guide to freeing storage on Mac.
The node_modules and .git problem
This is not Xcode-specific, but it hits developers who also do web development alongside iOS work.
If you keep JavaScript or TypeScript projects on your Desktop, every node_modules folder syncs to iCloud. A single React or Next.js project can have 300-500 MB of node_modules. Ten projects? That is 3-5 GB of npm packages in iCloud.
The same goes for .git directories. Every commit, branch, and blob in your repository history gets uploaded. A project with a couple years of history and some binary assets can have a .git folder that is 1-3 GB.
Read our dedicated guide on node_modules syncing to iCloud for specific fixes.
.gitignore does not help
A common misconception: adding folders to .gitignore will stop iCloud from syncing them. It does not.
.gitignore is a Git-only concept. It tells Git which files to exclude from version control. iCloud Drive has no knowledge of .gitignore files. iCloud syncs everything in Desktop and Documents regardless of what your .gitignore says.
The same goes for .dockerignore, .npmignore, and any other project-level ignore file. None of them affect iCloud.
The only way to exclude a specific file or folder from iCloud is to append .nosync to its name. For example, renaming node_modules to node_modules.nosync and creating a symlink. But this is fragile, breaks easily, and does not scale when you have dozens of projects.
How Desktop sync causes Xcode project folders to upload
Here is the typical scenario:
- You create a new Xcode project. You save it to your Desktop because it is convenient.
- macOS starts uploading the project to iCloud Drive. At first it is small — maybe 5 MB.
- You build the project. Xcode generates build artifacts inside the project folder. Now it is 200 MB.
- You add Swift Packages. SPM caches get created. Now it is 500 MB.
- You archive for TestFlight. The .xcarchive file adds another 400 MB.
- You do this for 5 more projects. Your Desktop is now syncing 3-5 GB of developer junk to iCloud.
And you are paying $2.99/month for the privilege of storing build caches in Apple's servers.
How to stop Xcode from eating iCloud storage
Here is the fix, step by step:
- Move all developer projects off Desktop and Documents. Create a
~/Developeror~/Projectsfolder (in your home directory, not inside Desktop or Documents). Move all your Xcode projects, web projects, and any code repositories there. This folder does not sync to iCloud. - Turn off Desktop & Documents sync. Go to System Settings > Apple ID > iCloud > iCloud Drive > turn off "Desktop & Documents Folders". macOS will create an "iCloud Drive (Archive)" folder with copies of everything. Your Desktop and Documents folders become local-only again.
- Clean up DerivedData. Run
rm -rf ~/Library/Developer/Xcode/DerivedData. This frees local disk space. If DerivedData was in a synced folder, the iCloud copies will be removed when you delete them from iCloud Drive in Finder. - Delete old archives. Open Xcode > Window > Organizer. Delete archives for apps you no longer ship or that you have already uploaded to App Store Connect. Each archive is 200 MB-1 GB.
- Clean Simulator data. iOS Simulators store runtime data in
~/Library/Developer/CoreSimulator/. This is local by default but can be 5-20 GB. Delete unused simulators: Xcode > Window > Devices and Simulators > right-click old simulators > Delete.
Read our full guide on how to stop Desktop syncing to iCloud for more details on step 2.
How much space you can recover
Here is what we typically see from iOS developers:
- DerivedData: 5-20 GB (local disk)
- Xcode archives: 2-10 GB
- Swift Package caches: 1-3 GB
- Simulator data: 5-15 GB (local disk)
- Project folders in iCloud: 3-10 GB of iCloud storage
Total recoverable: 10-30 GB between local and iCloud storage. If you are on the 50 GB iCloud plan, that could be enough to downgrade to free.
Preventing this in the future
The permanent fix is simple: never keep code projects in Desktop or Documents. Use ~/Developer, ~/Projects, or ~/Code — any folder in your home directory that is not synced to iCloud.
If you need Desktop & Documents sync for other reasons (sharing regular documents across devices), at least move your dev folders out. You can keep a shortcut or alias on your Desktop that points to ~/Developer if you want quick access.
And periodically clean DerivedData. Xcode does not clean up after itself. A monthly rm -rf ~/Library/Developer/Xcode/DerivedData keeps things under control.
Get iCloud Cleaner — $4.99
Automatically find Xcode junk, node_modules, .git folders, and other developer files eating your iCloud storage. Clean it up in 5 minutes.
Download iCloud Cleaner — $4.99