Awesome Open Source
Awesome Open Source

Xcode defaults

Check Markdown links License: CC BY-ND 4.0

Backup Xcode defaults

defaults read > ~/Desktop/XcodeDefaults.plist

Restore Xcode vanilla defaults

If you delete/move the current plist, Xcode will write a fresh one next time you run it.

killall Xcode
mv ~/Library/Preferences/ ~/Desktop/XcodeDefaults.plist
open -b

New Swift build system mode

With Xcode 13.3 the build system and Swift compiler have a new mode that better utilizes available cores, resulting in faster builds for Swift projects. The mode is opt-in, and you can enable globally with the following user default:

defaults write EnableSwiftBuildSystemIntegration 1

Source @BenchR

Enable project build time

defaults write ShowBuildOperationDuration -bool YES

Enable parallel builds for Swift

defaults write BuildSystemScheduleInherentlyParallelCommandsExclusively -bool YES

Disable parallel builds for Swift

Xcode 9.3 now runs more Swift build tasks in parallel with other commands. This may improve build times for Swift projects, but may also increase memory use during the build. This feature can be disabled from Terminal by setting a user default with

defaults write BuildSystemScheduleInherentlyParallelCommandsSerially -bool YES

Enable multi-cursor editing

defaults write PegasusMultipleCursorsEnabled -bool YES

Set maximum number of concurrent compile tasks

defaults write IDEBuildOperationMaxNumberOfConcurrentCompileTasks `sysctl -n hw.ncpu`

Where sysctl -n hw.ncpu gives you the number of CPU threads.

Set maximum number of parallel build subtasks

defaults write PBXNumberOfParallelBuildSubtasks `sysctl -n hw.ncpu`

Where sysctl -n hw.ncpu gives you the number of CPU threads.

Enable/Disable indexing

Enable indexing
defaults delete IDEIndexDisable
defaults write IDEIndexEnable -bool YES
Disable indexing
defaults delete IDEIndexEnable
defaults write IDEIndexDisable -bool YES

Show Indexing numeric progress

defaults write IDEIndexerActivityShowNumericProgress -bool YES

Show Indexing logging

This will show you why a particular file is having trouble being compiled for indexing.

defaults write IDEIndexShowLog -bool YES

Show prebuild step logs

defaults write IDEShowPrebuildLogs -bool YES

Set SourceKit log level

If set to SourceKit will write a log to /tmp with all the details of what it is doing while indexing. A lot of people find they have header hygiene problems or module problems that happen to work while building in certain configurations but aren't actually correct, resulting in missing modules or broken headers from the indexer's point of view. May not work anymore.

defaults write IDESourceKitServiceLogLevel -int 3 

Also you can do this temporarily by pre-pending this environment variable when starting Xcode:

SOURCEKIT_LOGGING=3 /Applications/

Source AppCode under the hood - Aydar Mukhametzyanov - NSSpain 2021

Disable Main Thread Checker

Deactivates the Main Thread Checker. Found in Xcode 12 release notes

defaults write DVTDisableMainThreadChecker 1

Enable internal Xcode (debug) menu

defaults write ShowDVTDebugMenu -bool YES

Disable automatic reopening of last project

Prevents Xcode from automatically restoring the last open project. This enables running multiple Xcode versions for different projects.

defaults write ApplePersistenceIgnoreState -bool YES

Some minimal additional logging

defaults write EnableDebugActivityLogs -bool YES

Enable build debugging mode

This slows down the build system & litters DerivedData//Build/Intermediates.noindex), generally should only be enabled when trying to capture a trace for incremental build debugging purposes.

defaults write EnableBuildDebugging -bool YES

Make Assistant aware of more companion files

Make Xcode's Assistant aware of your ViewModels, Views, etc. Found by @peterfriese

defaults write IDEAdditionalCounterpartSuffixes -array-add "ViewModel" "View" "Screen"

Disable move files on restructure

Do not move files when you restructure things in an Xcode project. Found by @steinpete

defaults write IDEDisableStructureEditingCoordinator -bool YES 

Disable state restoration

Stop Xcode from reopening files on launch. Found by @SmileyKeith

defaults write IDEDisableStateRestoration -bool YES

Homebrew prefix path

Homebrew's default prefix/install path can point to different locations depending on your system.
Xcode by default only looks for /opt/brew and /usr/local.
You can adjust that location by writing the following default.
To get your Homebrew prefix call brew --prefix. Source @NeoNacho

defaults write IDEHomebrewPrefixPath -string <BREW_PREFIX>

Swift package remote source path

Specify the directory to which remote source packages are fetch or expected to be found. xcodebuild has the same option as clonedSourcePackagesDirPath. Source @bguidolim

defaults write IDEClonedSourcePackagesDirPathOverride -string <PATH>

📱 Simulator

Enable Simulator fullscreen mode

defaults write AllowFullscreenMode -bool YES

🏗️ XCBuild

Enable Build Debugging

Creates an XCBuildData folder in ~/Library/Developer/Xcode/DerivedData/<your target>/Build/Intermediates.noindex/ which contains debugging info for xcodebuild.

defaults write -bool YES

🗑️ Xcode Cleanups

Remove all Xcode DerivedData

... provided Xcode is set to default folder locations. This is a quick win and helps to get back gigabytes of storage space. Do this regularly.

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

Remove all Xcode DeveloperTools cache files

... provided Xcode is set to default folder locations.

rm -rdf ${CACHE}
rm -rdf ${CACHE}org.llvm.clang.$(whoami)/ModuleCache
rm -rdf ${CACHE}org.llvm.clang/ModuleCache
rm -rdf ~/Library/Caches/*/*

Remove all Xcode / Swift temporary files.

rm -rdf ${TMP}*.swift
rm -rdf ${TMP}ibtool*
rm -rdf ${TMP}*IBTOOLD*
rm -rdf ${TMP}supplementaryOutputs-*
rm -rdf ${TMP}xcrun_db
rm -rdf ${TMP}sources-*
rm -rdf ${TMP}*
rm -rdf ${TMP}*

🧰 Tools

  • DevCleaner If you want to reclaim tens of gigabytes of your storage used for various Xcode caches - this tool is for you!
  • Kintsugi A tool to automatically resolve Git conflicts that occur in Xcode project files
  • BuildTimeAnalyzer A build time analyzer for Xcode
  • XCLogParser A tool to parse Xcode and xcodebuild logs stored in the xcactivitylog format
  • XCMetrics A tool to collect Xcode build metrics and improve developer productivity
Related Awesome Lists
Top Programming Languages
Top Projects

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
Swift (65,149
Awesome (13,404
Xcode (12,433
Apple (8,382
Developer Tools (6,237
Indexing (2,590
Userdefaults (240
Sourcekit (69