Skip to content

Instantly share code, notes, and snippets.

@tkersey

tkersey/swift.md

Last active Jan 27, 2021
Embed
What would you like to do?

2021

Automation

Foundation

SwiftUI

Xcode

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

  • swift-format

    provides the formatting technology for SourceKit-LSP and the building blocks for doing code formatting transformations.

  • SwiftLint

    A tool to enforce Swift style and conventions, loosely based on GitHub's Swift Style Guide.

  • IBLinter

    A linter tool to normalize .xib and .storyboard files. Inspired by realm/SwiftLint

  • ScanCode

    🔎 ScanCode detects licenses, copyrights, package manifests & dependencies and more by scanning code ... to discover and inventory open source and third-party packages used in your code.

  • periphery

    A tool to identify unused code in Swift projects

  • xiblint

    The xiblint script will test .xib and .storyboard files for compliance with best practices and team policies

  • xcassetscop

    Set rules for Xcode assets

  • ibcolortool

    Lists all of the colors used in Storyboards and XIB files.

  • xcprojectlint

    This project provides a security blanket, ensuring neither your co-workers, nor git screw up your Xcode project file. Some of the settings are arguably a matter of personal taste. Fortunately, each option can be enabled separately.

  • XcodeGen

    XcodeGen is a command line tool written in Swift that generates your Xcode project using your folder structure and a project spec. The project spec is a YAML or JSON file that defines your targets, configurations, schemes, custom build settings and many other options. All your source directories are automatically parsed and referenced appropriately while preserving your folder structure. Sensible defaults are used in many places, so you only need to customize what is needed. Very complex projects can also be defined using more advanced features.

  • mergepbx

    A tool for merging Xcode project files in git

  • xcperfect

    Make your xccov outputs prettier

  • xcderiveddata

    A command-line utility that prints the path of the derived data directory for the current Xcode project

  • LibFuzzer

    is in-process, coverage-guided, evolutionary fuzzing engine

  • SwiftMonkey

    a framework for generating randomised user input in iOS apps. This kind of monkey testing is useful for stress-testing apps and finding rare crashes

  • xcparse

    A command line tool to extract code coverage & screenshots from Xcode 11 XCResult files

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