Coder Social home page Coder Social logo

ctreffs / xcode-defaults Goto Github PK

View Code? Open in Web Editor NEW
909.0 33.0 38.0 63 KB

Awesome and useful Xcode defaults

Home Page: https://developer.apple.com/xcode/

License: Other

xcode userdefaults awesome xcode-defaults user-defaults com-apple-dt-xcode developer-tools apple

xcode-defaults's Introduction

Xcode defaults

Check Markdown links License: CC BY-ND 4.0

Backup Xcode defaults

defaults read com.apple.dt.Xcode > ~/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/com.apple.dt.Xcode.plist ~/Desktop/XcodeDefaults.plist
open -b com.apple.dt.Xcode

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 com.apple.dt.XCBuild EnableSwiftBuildSystemIntegration 1

Source @BenchR

Enable project build time

defaults write com.apple.dt.Xcode ShowBuildOperationDuration -bool YES

Enable parallel builds for Swift

defaults write com.apple.dt.Xcode 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 com.apple.dt.Xcode BuildSystemScheduleInherentlyParallelCommandsSerially -bool YES

Enable multi-cursor editing

defaults write com.apple.dt.Xcode PegasusMultipleCursorsEnabled -bool YES

Set maximum number of concurrent compile tasks

defaults write com.apple.dt.Xcode 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 com.apple.dt.Xcode PBXNumberOfParallelBuildSubtasks `sysctl -n hw.ncpu`

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

Enable/Disable indexing

Keep in mind that disabling indexing will disable refactor code action so you probably won't be able to generate protocol conformances or memberwise initializers

Enable indexing
defaults delete com.apple.dt.Xcode IDEIndexDisable
defaults write com.apple.dt.Xcode IDEIndexEnable -bool YES
Disable indexing
defaults delete com.apple.dt.Xcode IDEIndexEnable
defaults write com.apple.dt.Xcode IDEIndexDisable -bool YES

Show Indexing numeric progress

defaults write com.apple.dt.Xcode IDEIndexerActivityShowNumericProgress -bool YES

Show Indexing logging

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

defaults write com.apple.dt.Xcode IDEIndexShowLog -bool YES

Show prebuild step logs

defaults write com.apple.dt.Xcode 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 com.apple.dt.Xcode IDESourceKitServiceLogLevel -int 3 

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

SOURCEKIT_LOGGING=3 /Applications/Xcode.app/Contents/MacOS/Xcode

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 com.apple.dt.Xcode DVTDisableMainThreadChecker 1

Enable internal Xcode (debug) menu

defaults write com.apple.dt.Xcode 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 com.apple.dt.Xcode ApplePersistenceIgnoreState -bool YES

Some minimal additional logging

defaults write com.apple.dt.XCBuild 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 com.apple.dt.XCBuild 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 com.apple.dt.Xcode 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 com.apple.dt.Xcode IDEDisableStructureEditingCoordinator -bool YES 

Disable state restoration

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

defaults write com.apple.dt.Xcode 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 com.apple.dt.Xcode 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 com.apple.dt.Xcode IDEClonedSourcePackagesDirPathOverride -string <PATH>

๐Ÿ“ฑ Simulator

Enable Simulator fullscreen mode

defaults write com.apple.iphonesimulator 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 com.apple.dt.XCBuild -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/*
rm -rf $(defaults read com.apple.dt.Xcode.plist IDECustomDerivedDataLocation)

Remove all Xcode DeveloperTools cache files

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

CACHE=$(getconf DARWIN_USER_CACHE_DIR)
rm -rdf ${CACHE}com.apple.DeveloperTools
rm -rdf ${CACHE}org.llvm.clang.$(whoami)/ModuleCache
rm -rdf ${CACHE}org.llvm.clang/ModuleCache
rm -rdf ~/Library/Caches/com.apple.dt.*/*

Remove all Xcode / Swift temporary files.

TMP=$(getconf DARWIN_USER_TEMP_DIR)
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}com.apple.dt.*
rm -rdf ${TMP}com.apple.test.*

๐Ÿงฐ 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

xcode-defaults's People

Contributors

0xwdg avatar ctreffs avatar dmaclach avatar jackoplane avatar jeffctown avatar maximkrouk avatar nssina avatar owenworley avatar renovate[bot] avatar wei18 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xcode-defaults's Issues

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

This repository currently has no open or pending branches.

Detected dependencies

github-actions
.github/workflows/markdown-link-check.yml
  • gaurav-nelson/github-action-markdown-link-check 1.0.15

  • Check this box to trigger a request for Renovate to run again on this repository

Behavior of IDEBuildOperationTimingLogLevel

Enable extensive per operation timing logs

defaults write com.apple.dt.Xcode IDEBuildOperationTimingLogLevel -int 3

Can you explain what this actually affects? Turing on and off I can't see any difference.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.