Useful macOS defaults: Xcode
com.apple.dt.Xcode controls how Xcode looks and behaves. Xcode has a large number of hidden settings that are not in the Settings window.
After changing these, quit and reopen Xcode.
Show build times in the toolbar
Display how long each build takes in the activity bar at the top of the Xcode window:
defaults write com.apple.dt.Xcode ShowBuildOperationDuration -bool true
This is one of the most popular Xcode defaults. You see the build time right after each build finishes.
Show line numbers
Show line numbers in the gutter:
defaults write com.apple.dt.Xcode DVTTextShowLineNumbers -bool true
You can also turn this on in Xcode, then Settings, then Text Editing, then Display.
Show code folding ribbon
Show the folding ribbon in the gutter (the grey strip that lets you collapse blocks of code):
defaults write com.apple.dt.Xcode DVTTextShowFoldingSidebar -bool true
Show invisible characters
Show spaces, tabs, and line endings:
defaults write com.apple.dt.Xcode DVTTextShowInvisibleCharacters -bool true
Trim trailing whitespace
Remove whitespace at the end of lines when saving:
defaults write com.apple.dt.Xcode DVTTextEditorTrimTrailingWhitespace -bool true
Also trim whitespace on lines you did not edit:
defaults write com.apple.dt.Xcode DVTTextEditorTrimWhitespaceOnlyLines -bool true
Indentation
Use spaces instead of tabs:
defaults write com.apple.dt.Xcode DVTTextIndentUsingTabs -bool false
Set the indent width (number of spaces):
defaults write com.apple.dt.Xcode DVTTextIndentWidth -int 4
Set the tab width:
defaults write com.apple.dt.Xcode DVTTextTabWidth -int 4
Page guide
Show a vertical line at a specific column (useful for keeping lines short):
defaults write com.apple.dt.Xcode DVTTextPageGuideLocation -int 80
defaults write com.apple.dt.Xcode DVTTextShowPageGuide -bool true
Minimap
Show the code minimap on the right side of the editor:
defaults write com.apple.dt.Xcode DVTTextShowMinimap -bool true
Maximum number of concurrent compile tasks
Set how many files Xcode compiles at the same time. By default, Xcode uses the number of CPU cores:
defaults write com.apple.dt.Xcode IDEBuildOperationMaxNumberOfConcurrentCompileTasks 8
Set this to a lower number if builds make your Mac unresponsive, or higher if you have cores to spare.
Disable source control
Turn off the built-in Git integration:
defaults write com.apple.dt.Xcode IDESourceControlEnableSourceControl -bool false
Some developers prefer to use Git from the command line or a dedicated Git app.
Show all build settings
Show the raw build settings in the build settings editor (including the setting names, not just the display names):
defaults write com.apple.dt.Xcode IDEBuildSettingsShowRawValues -bool true
Enable internal debug menu
defaults write com.apple.dt.Xcode ShowDVTDebugMenu -bool true
This adds a Debug menu with tools for inspecting Xcode itself.
Derived data location
Read where Xcode stores its build artefacts:
defaults read com.apple.dt.Xcode IDECustomDerivedDataLocation
You can set a custom location:
defaults write com.apple.dt.Xcode IDECustomDerivedDataLocation -string "/path/to/DerivedData"
Or clear it to go back to the default (~/Library/Developer/Xcode/DerivedData):
defaults delete com.apple.dt.Xcode IDECustomDerivedDataLocation
Disable the "Welcome to Xcode" window
Stop the welcome window from appearing every time you open Xcode:
defaults write com.apple.dt.Xcode XCShowWelcomeWindow -bool false
Faster animation in the Interface Builder
Speed up the animations in the Interface Builder canvas:
defaults write com.apple.dt.Xcode IDEInterfaceBuilderCanvasAnimationSpeed -float 0.1
Parallel testing
Set the number of parallel test runners:
defaults write com.apple.dt.Xcode IDESimulatorParallelTestMaxCount -int 4
Read all current Xcode settings
defaults read com.apple.dt.Xcode
The output is very long. Filter it:
defaults read com.apple.dt.Xcode | grep -i "DVTText"
defaults read com.apple.dt.Xcode | grep -i "build"
Notes
Xcode has hundreds of hidden defaults. The ones above are the most widely used. Many more are documented in Apple developer forums and community blogs.
Some settings use the DVT prefix (Developer Tools) and others use IDE (Integrated Development Environment). Both are valid Xcode settings.
Enjoyed this post?
Well, you could share the post with others, follow me with RSS Feeds and/or send me a comment via email.
Tags
Category:
Tags:
Year: