I write a lot of code using Xcode. I know Xcode creates temporary files when it builds. These seem to be quite large (GB’s), and I would like to exclude them from Time Machine backups.
How can I exclude them ? Where are they located? Is the location always the same?
2
Answers
~/Library/Developer
to exclusion listFor the most part, these items are already excluded from Time Machine backups, through the use of the HFS+/APFS
com.apple.metadata:com_apple_backup_excludeItem
extended attribute bit that is set for build-related directories in these folders.Take, for instance, the following:
This shows the
CoreSimulator/Caches
directory has thecom.apple.metadata:com_apple_backup_excludeItem
extended attribute set with the binary plist version of the following XML plist:This effectively excludes this folder and contents from Time Machine backups. Likewise, the directories inside
~/Library/Developer/CoreSimulator/Devices
all have the samecom.apple.metadata:com_apple_backup_excludeItem
extended attribute set. Most stuff in the DerivedData is also excluded (saveUnsaved_Xcode_Documents
).Note that
~/Library/Developer/Xcode/UserData
contains your CodeSnippets, Custom Key bindings, font and color themes, and other data that you’d likely want backed up.Apple’s pretty good about excluding that kind of stuff from backups automatically.
Also of note is that I believe the
.nobackup
suffix can be used on directories to prevent the contents from being backed up, and similarly,.noindex
to prevent the contents from being indexed by Spotlight.