SwiftFormat for Xcode for Mac

The latest version of SwiftFormat for Xcode for Mac is 0.64.7, released . Xcode Extension for reformatting Swift code.

What's new in SwiftFormat for Xcode 0.64.7

  • Added --prefer-us-spelling and --preserve-iff options to commonTypos
  • Fixed hoistTry and hoistAwait failing to terminate with deeply nested expressions
  • Fixed crashes when tokenizing shifts by negative integers
  • Fixed comparisons before generic type members and << before implicit members being mistaken for generic argument lists
  • Fixed unusedArguments crashing on lifetime attributes without arguments and leaving duplicate underscores in unnamed parameters
  • Fixed nestedIf crashing when merging conditions with trailing comments
Show 14 more
  • Fixed preferKeyPath producing invalid code inside Swift Testing's #expect and #require macros
  • Fixed noForceUnwrapInTests introducing nested #require macros
  • Fixed forWhere changing operator precedence when joining conditions containing &&
  • Fixed preferForLoop converting closures with returns inside nested loops
  • Fixed redundantSelf treating parameter pack expansions as repeat loops
  • Fixed noExplicitOwnership removing consuming and borrowing used as names
  • Fixed singlePropertyPerLine splitting value generic parameters
  • Fixed yodaConditions treating macro arguments as constants
  • Fixed preferSwiftTesting removing spaces after comparison operators
  • Fixed blockComments leaving empty comment lines before over-indented closing delimiters
  • Fixed spaces around & and -> in types wrapped over multiple lines
  • Improved parsing of consuming modifiers and properties named open
  • Documented member-chain indentation and clarified letter-case options in numberFormatting help
  • Updated the Swift toolchain and static SDK used for Linux release builds

Source: github.com

How to update SwiftFormat for Xcode on your Mac

SwiftFormat for Xcode version history

  1. 0.64.7
  2. 0.64.6
    • Fixed parsing of value generic parameters, negative integer arguments, integer constraints, and inline-array types
    • Fixed opaqueGenericParameters and simplifyGenericConstraints producing invalid code when formatting value generics
    • Updated redundantSelf to preserve self in Logger calls by default, and made --self-required extend the default list
    • Fixed organizeDeclarations and docComments separating conditional attributes and documentation from their declarations
    • Fixed custom prefix / operators being mistaken for regex literals and causing incorrect lint line numbers
    • Fixed parsing of tuple types containing parameter pack expansions
    • Fixed Xcode-style indentation of wrapped type conformances
    • Fixed preferSwiftTesting converting XCTest cases with conditionally compiled overrides or references to Swift Testing type names
    • Updated test suite rules to preserve open classes that may be subclassed
    • Fixed singlePropertyPerLine splitting tuple destructuring when the value count does not match
    • Fixed redundantSendable removing Sendable from @usableFromInline types
    • Fixed redundantClosure removing trailing closure arguments followed by a call
    • Fixed handling of unsafe expressions in braces, redundantClosure, redundantParens, and unusedArguments
    • Fixed numberFormatting grouping digits in availability version numbers
    • Fixed trailingCommas adding commas to #warning, #error, and other directives
    • Fixed hoistTry and hoistAwait joining keywords to preceding keywords
    • Fixed yodaConditions corrupting comparisons wrapped after the operator or containing macro calls
    • Fixed redundantInit removing .init when a function parameter shadows the type name
    • Fixed redundantBackticks removing required backticks from type members named Protocol
    • Fixed opaqueGenericParameters introducing some inside generic arguments of closure typealiases
    • Fixed redundantParens removing required parentheses around optional opaque protocol compositions
    • Fixed extensionAccessControl hoisting fileprivate onto extensions of private types
    • Fixed duplicateImports removing imports with different SPI names
    • Fixed preferExplicitFalse breaking parenthesized conditional compilation conditions
    • Fixed preferLazyMap making closures that capture inout values escape

    Source: github.com

  3. 0.64.5
    • Fixed filtered config sections applying to files that do not match, and made matching sections apply in order
    • Improved handling of unsafe in for loops and expression parsing
    • Fixed unusedArguments removing arguments referenced by lifetime attributes
    • Fixed redundantEquatable removing == when stored properties are conditionally compiled
    • Fixed preferForLoop converting forEach calls used as expressions
    • Fixed noForceUnwrapInTests converting force unwraps inside key paths
    • Fixed hoistTry placement around comments, member chains after closures, and multiline declarations
    • Fixed environmentEntry placing default values after attributes on separate lines
    • Fixed braces joining closure statements onto preceding closing braces
    • Fixed redundantClosure treating parentheses on a new line as a call
    • Fixed redundantReturn removing early returns in branches ending with throw
    • Fixed extensionAttributes doubling comment indentation after removed attributes
    • Updated duplicateImports to remove ordinary duplicate imports across code boundaries
    • Fixed docComments leaving trailing spaces when converting documentation comments

    Source: github.com

  4. 0.64.4
    • Fixed redundantReturn removing required returns when nested conditional branches all throw
    • Updated nestedIf to flatten nested else { if ... } branches into else if chains
    • Fixed command-line handling of paths after the -- end-of-options separator
    • Fixed CLI warning tests hanging while waiting for stdin when run in isolation

    Source: github.com

  5. 0.64.3
    • Fixed andOperator replacing && with commas inside ternary expression branches
    • Fixed trailingClosures attaching a parenthesized closure on a new line to the preceding statement

    Source: github.com

  6. 0.64.2
    • Fixed severe indent performance regression on large arrays of multiline initializers
    • Improved handling of #if directives in single-expression bodies, including return removal and SwiftUI formatting
    • Fixed unreachable-code warnings when building JSON encoding code with newer Swift versions
    • Fixed Windows release build setup

    Source: github.com

  7. 0.64.1
    • Fixed nestedIf and repeatedGuard losing condition wrapping when merging statements
    • Fixed wrapArguments wrapping condition lists when line breaks occur only inside individual clauses
    • Fixed wrapEnumCases skipping cases declared after a raw value
    • Fixed propertyTypes dropping .init before a force unwrap or trailing closure
    • Fixed redundantReturn removing required bare returns from do throws(...) bodies
    • Fixed redundantSelf missing local variables declared after a trailing closure
    • Fixed redundantOverload removing overloads in types that declare a conformance
    • Fixed braces moving opening braces onto conditional compilation directive lines
    • Improved indentation and wrapping of multiline if and guard conditions

    Source: github.com

  8. 0.64.0
    • Added --snapshot feature for incrementally adopting formatting without changing files that match a saved snapshot
    • Added --unknown-options error|warn|ignore for handling unknown rules, options, and unsupported option values
    • Added --color auto|always|never to control colored command-line output
    • Added nestedIf rule to merge nested if statements
    • Added repeatedGuard rule to merge consecutive guard statements with identical bodies
    • Added redundantEnumerated rule to remove unused enumeration indices from for loops
    • Added extensionAttributes rule to hoist common member attributes onto extensions
    • Added contentBuilder rule, replacing redundantViewBuilder, with --content-builder and --prefer-content-builder options
    • Added commonTypos rule, with --typo-visibility, --typos, and --ignore-typos options
    • Added forWhere rule with --for-where always|never
    • Added redundantOverload rule to replace forwarding overloads with default arguments
    • Added preferStructSwiftTestingSuites rule
    • Added wrapClosureBodies, wrapDoBodies, and wrapSingleLineStrings rules
    • Added header-creation-date-after: config filters for applying rules based on file header dates
    • Added --scope-blank-lines remove|preserve for function bodies, closures, and statement blocks
    • Added --wrap-single-line-enum-cases option, defaulting to false
    • Added --acronym-visibility option, defaulting to internal
    • Added --blank-line-after-switch-case never option
    • Added --hoist-imports hoist|preserve option, defaulting to hoist
    • Added --excluded-declaration-types option for the docComments rule
    • Added attributes-last import grouping and made import grouping order configurable
    • Added support for sorting array and dictionary literals with swiftformat:sort directives
    • Updated SwiftUI rules to support @ContentBuilder
    • Updated redundantExtendedLifetime to handle write-only references and underscored assignments
    • Updated redundantParens to handle optional opaque types in Swift 6.4
    • Updated noForceUnwrapInTests to handle force unwraps on the RHS of operators and place try at the start of the expression
    • Renamed privateStateVariables to privateSwiftUIDynamicProperties and expanded it to other SwiftUI dynamic properties in views and view modifiers
    • Fixed noForceUnwrapInTests using stale function body ranges and placing try before assignment targets
    • Fixed indentation of multiline conditions, method chains, closures, and wrapped case patterns
    • Fixed redundantSelf and redundantStaticSelf modifying code outside the requested line range
    • Fixed redundantReturn removing required returns before expressions in Void functions
    • Fixed formatting of read and modify accessors
    • Fixed directive handling performance with multiline strings
    • Fixed organizeDeclarations timeouts when declarations share a line
    • Fixed crash in organizeDeclarations rule when opening brace line has a trailing comment
    • Improved formatting performance and reduced repeated parsing and configuration work
    • Preserved unchanged editor lines when formatting in Xcode
    • SwiftFormat now excludes .build, Build, and DerivedData directories from formatting/linting by default
    • Removed CocoaPods distribution and the prebuilt binary from the repository (use Swift Package Manager or release downloads instead)

    Source: github.com

  9. 0.63.1
    • Added --locale option for deterministic sorting
    • Added --boolean-guards-in-tests option, defaulting to preserve
    • Updated the default modifier order for convenience to match Apple conventions
    • Fixed sortDeclarations handling of trailing whitespace and comments
    • Fixed preferSwiftStringAPI modifying replacingOccurrences(of: "", with: ...)
    • Fixed disable:next handling in multiline strings
    • Fixed docComments incorrectly converting nested function comments when preceded by executable code
    • Fixed swiftTestingTestCaseNames removing unnamed argument underscores and pluralized acronyms
    • Fixed sortImports treating package imports as unlabeled
    • Fixed indent adding line-wrap indentation to wrapped function names
    • Fixed indent of wrapped case patterns with --indent-case true
    • Fixed preferSwiftTesting adding duplicate default suite attributes
    • Fixed hoistTry placement across infix expressions with trailing closures
    • Fixed building the project with Xcode 27

    Source: github.com

  10. 0.63.0
    • Added ifExpressions rule to convert ternaries to if expressions
    • Added preferLazyMap rule
    • Added redundantExtendedLifetime rule
    • Added ‹!-- no-format --> HTML comment syntax for disabling formatting of markdown code blocks
    • Added warning when --enable is used for a rule that is already enabled by default
    • Added --redundant-optional-binding option, defaulting to same-name-only
    • Made --wrapstringinterpolation preserve the default
    • Changed default of --single-line-ternary to convert
    • Distinguished default, opt-in, and deprecated rules in --rules and --rule-info output
    • Updated organizeDeclarations to categorize associatedtype declarations as beforeMarks
    • Updated hoistAwait and hoistTry to automatically detect and preserve autoclosures within same file as definition
    • Updated redundantType and propertyTypes to support more ExpressibleByXLiteral types
    • Updated redundantReturn to preserve bare return in closures where removal would create single-expression body
    • Updated redundantOptionalBinding to convert if let x = property to if let property
    • Updated urlMacro rule to support try #require(URL(string:)) pattern
    • Updated redundantBackticks to preserve backticks on Swift Testing @Test functions
    • Updated swiftTestingTestCaseNames to convert backticked names with test prefix or underscores
    • Updated genericExtensions rule to support collection types
    • Updated unusedPrivateDeclarations to preserve properties used in compiler-generated Equatable and Hashable conformances
    • Increased stack size to 1MB for Linux release builds
    • Fixed redundantClosure false positive for if statements with no else branch
    • Fixed spaces around module selectors in generics
    • Fixed preferForLoop incorrectly applying to dollar-prefixed identifiers
    • Fixed blank line before trailing infix operators
    • Fixed swiftTestingTestCaseNames not adding backticks when required
    • Fixed --preserve-acronyms to work as substring match, not just exact identifier match
    • Fixed genericExtensions rule leaving stray comma with additional where conditions
    • Fixed indent dropping switch case body indentation inside #if with --ifdef no-indent
    • Fixed redundantSwiftUIGroup removing Group(subviews:)
    • Fixed redundantReturn removing redundant returns from switch/if inside a flatMap closure
    • Fixed --ifdef no-indent indentation for method chains and directives
    • Fixed environmentEntry edge cases
    • Fixed redundantInternal stripping required internal inside #if in non-internal extensions
    • Fixed indent of trailing closure in method chain member inside #if
    • Fixed spaceAroundParens spurious violations for keyword identifiers after :: module selector

    Source: github.com

Details

Latest version
0.64.7
Released
Last checked
Website
github.com
Homebrew cask
swiftformat-for-xcode