Skip to content

Instantly share code, notes, and snippets.

@tkersey

tkersey/swift.md

Last active Nov 24, 2020
Embed
What would you like to do?

2020

Apps

Auto Layout

Combine

Crash reporting

Libraries

Performance

Swift

SwiftUI

Xcode

Xcode shortcuts

  • Go Back to Where the Cursor Is: ⌥ + ⌘ + L
  • Copy Qualified Symbol Name: ⌘ + ⇧ + ⌥ + ⌃ + C
  • Fix All Errors In-Scope: ⌃+ ⌥ + ⌘ + F
  • Jump to Definition: ⌃ + ⌘ + J
  • Find Call Hierarchy: ⇧ + ⌃ + ⌘ + H
  • Search & Replace in the whole project: ⇧ + ⌥ + ⌘ + F

2019

Automation

Xcode

Before 2019

Debugging

Design

Development

Foundation

Programming

SDK

Shortcuts

  • ⌃⌥⌘F in Xcode to apply all fix-its in the current scope.

Snippets

  • Xcode build duration
    defaults write com.apple.dt.Xcode ShowBuildOperationDuration -bool YES
  • Xcode reload plugins
    defaults delete com.apple.dt.Xcode DVTPlugInManagerNonApplePlugIns-Xcode-X.X.X
  • Better autocompletion with Fuzzy mode?
    defaults write com.apple.dt.Xcode IDECodeCompletionFuzzyMode 3
    defaults write com.apple.dt.Xcode IDEWorkaroundForRadar6288283 3
  • Faster build times by leveraging multi-core CPU
    defaults write com.apple.dt.Xcode IDEBuildOperationMaxNumberOfConcurrentCompileTasks `sysctl -n hw.ncpu`
  • Flag to emit warnings whenever a function takes longer than some threshold to compile. Add the following to Other Swift Flags
    • -Xfrontend
    • -warn-long-function-bodies=100, where 100 is the number of milliseconds you’d like the warning threshold to be
  • More information about why build commands are run defaults write http://com.apple .dt.Xcode ExplainWhyBuildCommandsAreRun -bool true
  • To enable warn about individual expressions that take a long time to type check, go the Build Settings, “Swift Compiler - Custom Flags”, “Other Swift Flags”, and add: -Xfrontend -warn-long-expression-type-checking=<limit> where <limit> is the lower limit of the number of milliseconds that an expression must take to type check in order for the warning to be emitted.
  • An experimental opt-in feature increases the number of concurrent build tasks that are run for Swift projects. This may improve build times for Swift projects, but may also increase memory use during the build: defaults write com.apple.dt.Xcode BuildSystemScheduleInherentlyParallelCommandsExclusively -bool NO

Swift

Testing

Videos

Xcode

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.