跳到正文

SwiftFormat for Xcode 版本记录

Nick Lockwood · 用于从 Xcode 的 Editor 菜单重新格式化 Swift 代码的源代码编辑器扩展。

Cask开发工具 8,964
主页
安装命令
brew install --cask swiftformat-for-xcode
近 30 天安装
373
App榜第 552
近一年安装
2,533
365 天累计
最新版本
0.64.7
下载大小
10MB
zip
更新节奏
每周
近 30 天 2 个版本
  1. 0.64.7

    最新补丁

    OpenNavo 编辑 Homebrew 收录

    SwiftFormat for Xcode 0.64.7 增加拼写选项,并修复会崩溃或错误改写 Swift 的规则。

    SwiftFormat for Xcode 0.64.7 于 2026 年 11 月 14 日发布,为 commonTypos 增加拼写选项,并修复会崩溃或错误改写 Swift 代码的规则。来源:https://github.com/nicklockwood/SwiftFormat/releases/tag/0.64.7

    • commonTypos 增加 --prefer-us-spelling 和 --preserve-iff。
    • hoistTry 和 hoistAwait 不再在深层嵌套上无法结束。
    • 负整数移位不再使词法分析器崩溃。
    • preferKeyPath 不再在 #expect 和 #require 内生成无效代码。
    • forWhere 在用 && 连接条件时不再改变运算符优先级。
    • unusedArguments 不再在没有参数的生命周期属性上崩溃。
  2. 0.64.6

    补丁

    OpenNavo 编辑 Homebrew 收录

    SwiftFormat for Xcode 0.64.6 于 2026-11-06 发布。本次更新修复了 value generics、tuple pack expansions 的解析问题,以及若干会把合法 Swift 代码改写错误的规则。

    • 修复 value generic parameters、负整数实参、整数约束和 inline-array 类型的解析问题。
    • 修复 opaqueGenericParameters 和 simplifyGenericConstraints 在格式化 value generics 时生成无效代码的问题。
    • redundantSelf 现在默认在 Logger 调用中保留 self,--self-required 会扩展默认列表。
    • 修复 organizeDeclarations 和 docComments 将条件属性及文档注释与其声明分离的问题。
    • 修复自定义前缀 / 运算符被误识别为正则字面量,进而导致 lint 行号错误的问题。
    • 修复包含 parameter pack expansions 的 tuple 类型解析问题。
    • 修复换行后的 type conformances 在 Xcode 风格下的缩进问题。
    • 修复 preferSwiftTesting 在转换带条件编译 override 或引用 Swift Testing 类型名的 XCTest 用例时的问题。
    • 更新 test suite 相关规则,保留可能被继承的 open 类。
    • 修复 singlePropertyPerLine 在值数量不匹配时拆分 tuple destructuring 的问题。
    • 修复 redundantSendable 从 @usableFromInline 类型移除 Sendable 的问题。
    • 修复 redundantClosure 删除后面紧跟调用的 trailing closure 实参的问题。
    • 修复 braces、redundantClosure、redundantParens 和 unusedArguments 对 unsafe 表达式的处理。
    • 修复 numberFormatting 对可用性版本号中的数字分组。
    • 修复 trailingCommas 向 #warning、#error 及其他指令添加逗号的问题。
    • 修复 hoistTry 和 hoistAwait 将关键字与前面的关键字连在一起的问题。
    • 修复 yodaConditions 破坏运算符后换行或包含宏调用的比较。
    • 修复 redundantInit 在函数参数遮蔽类型名时移除 .init 的问题。
    • 修复 redundantBackticks 移除名为 Protocol 的类型成员所必需的反引号。
    • 修复 opaqueGenericParameters 在闭包 typealias 的泛型参数中引入 some 的问题。
    • 修复 redundantParens 移除可选不透明协议组合所必需的括号。
    • 修复 extensionAccessControl 将 fileprivate 提升到 private 类型的 extension 上。
    • 修复 duplicateImports 移除 SPI 名称不同的 import。
    • 修复 preferExplicitFalse 破坏带括号的条件编译条件。
    • 修复 preferLazyMap 使捕获 inout 值的闭包发生逃逸。
  3. 0.64.5

    补丁

    OpenNavo 编辑 Homebrew 收录

    SwiftFormat for Xcode 0.64.5 于 2026-10-31 发布,修复了配置匹配、解析以及多条格式化规则中的边界情况。

    • 带过滤条件的配置分节不再作用于不匹配的文件,匹配的分节会按顺序生效。
    • 改进了 for 循环中 unsafe 的处理以及表达式解析。
    • unusedArguments 不再删除被生命周期属性引用的参数。
    • 当存储属性使用条件编译时,redundantEquatable 不再删除 ==。
    • preferForLoop 不再转换作为表达式使用的 forEach 调用。
    • noForceUnwrapInTests 不再转换键路径中的强制解包。
    • hoistTry、environmentEntry、braces、redundantClosure、redundantReturn、extensionAttributes 和 docComments 修复了位置、缩进和行尾空格问题。
    • duplicateImports 现在会跨代码边界删除普通的重复导入。
  4. 0.64.4

    展开

    OpenNavo 编辑 Homebrew 收录

    修复抛出分支中的冗余 return 删除、嵌套 if 展平以及命令行路径处理。

    SwiftFormat for Xcode 0.64.4 于 2026-10-27 发布,包含对格式化规则和命令行的四项修复。

    • redundantReturn 在嵌套条件语句的每个分支都抛出异常时,不再删除仍然必需的 return。
    • nestedIf 现在会将嵌套的 else { if ... } 分支展平为 else if 链。
    • 命令行可以处理 -- 选项结束分隔符之后的路径。
    • CLI 警告测试单独运行时不再因等待标准输入而挂起。
  5. 0.64.3

    展开

    OpenNavo 编辑 Homebrew 收录

    修复三元分支内的 andOperator 以及 trailingClosures 附加下一行闭包的问题。

    SwiftFormat for Xcode 0.64.3 于 2026-10-26 发布,包含两项规则修复。

    • andOperator 不再将三元表达式各分支内的 && 替换为逗号。
    • trailingClosures 不再将位于新行的带括号闭包附加到上一条语句。
  6. 0.64.2

    展开

    GitHub Release Homebrew 收录

    • 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
  7. 0.64.1

    展开

    OpenNavo 编辑 Homebrew 收录

    修复条件换行与缩进,以及枚举、属性、返回、self、重载和花括号规则。

    修复 nestedIf 和 repeatedGuard 合并语句时丢失条件换行。wrapArguments 不再因单个条件内部换行而重排整个条件列表;wrapEnumCases 能处理原始值后声明的枚举 case。

    修复 propertyTypes 在强制解包或尾随闭包前丢弃 .init、redundantReturn 从 do throws(...) 体移除必需的空 return、redundantSelf 漏识别尾随闭包后声明的局部变量、redundantOverload 移除声明协议遵循的类型中的重载。修复 braces 将左花括号移到条件编译指令所在行。改善多行 if/guard 的缩进和换行。

    https://github.com/nicklockwood/SwiftFormat/releases/tag/0.64.1

  8. 0.64.0

    展开

    OpenNavo 编辑 Homebrew 收录

    新增基于快照的增量格式化,以及嵌套 if、重复 guard、未使用枚举索引和内容构建器等规则。改善格式化性能,保留 Xcode 编辑器中未修改的行,默认排除 .build、Build 和 DerivedData。

    新增基于快照的增量格式化,以及嵌套 if、重复 guard、未使用枚举索引和内容构建器等规则。改善格式化性能,保留 Xcode 编辑器中未修改的行,默认排除 .build、Build 和 DerivedData。

    Source

  9. 0.63.1

    展开

    OpenNavo 编辑 Homebrew 收录

    新增排序和测试相关选项,更新 convenience 修饰符的默认顺序,修复多项格式处理和规则问题,并修复使用 Xcode 27 构建项目的问题。

    新增
    新增 --locale,用于确定性排序。新增 --boolean-guards-in-tests;默认值为 preserve。
    变更
    更新 convenience 修饰符的默认顺序,使其符合 Apple 惯例。
    修复
    修复声明和导入排序、空白、注释及 package 导入处理。修复字符串 API、多行字符串和文档注释规则的处理。修复测试名称、缩进、Swift Testing 和 hoistTry 行为。修复使用 Xcode 27 构建项目的问题。

    SwiftFormat 0.63.1 新增 --locale 选项以实现确定性排序,并新增 --boolean-guards-in-tests,其默认值为 preserve。convenience 的默认修饰符顺序现与 Apple 惯例一致。

    本版本修复了 sortDeclarations 对尾随空白和注释的处理、preferSwiftStringAPI 修改搜索字符串为空的 replacingOccurrences 调用,以及 disable:next 在多行字符串中的行为。docComments 不再在可执行代码之后错误地转换嵌套函数注释。swiftTestingTestCaseNames 不再移除未命名参数的下划线,也不再将缩写词改为复数。sortImports 不再把 package 导入视为未标记导入。缩进修复涵盖换行函数名,以及启用 --indent-case true 时换行的 case 模式。其他修复阻止 preferSwiftTesting 添加重复的默认套件属性,并纠正 hoistTry 在带尾随闭包的中缀表达式中的位置。本版本还修复了使用 Xcode 27 构建项目的问题。

    来源:https://github.com/nicklockwood/SwiftFormat/releases/tag/0.63.1

  10. 0.63.0

    展开

    OpenNavo 编辑 Homebrew 收录

    新增格式化规则和选项,更新对 Swift 语法及规则报告的处理,并修复多项格式化规则和命令行选项问题。

    新增
    新增 ifExpressions、preferLazyMap 和 redundantExtendedLifetime 规则。新增 <!-- no-format -->,用于禁用 Markdown 代码块的格式化。对已默认启用的规则使用 --enable 时发出警告。新增 --redundant-optional-binding;默认值为 same-name-only。
    更新
    --single-line-ternary 的默认值改为 convert。更新对 Swift 语法、类型和 Swift Testing 的规则支持。规则输出现在区分默认、选择启用和已弃用规则。
    修复
    修复格式化边缘问题,包括缩进和误报。修复模块选择器、泛型和条件编译的处理问题。Linux 发布构建的堆栈大小增加到 1 MB。

    SwiftFormat 0.63.0 新增 ifExpressions、preferLazyMap 和 redundantExtendedLifetime 规则,并加入用于禁用 Markdown 代码块格式化的 <!-- no-format --> HTML 注释语法。新增 --redundant-optional-binding,默认值为 same-name-only;当 --enable 用于启用默认已开启的规则时,也会发出警告。--single-line-ternary 的默认值改为 convert,--wrapstringinterpolation 则保留其默认值。规则输出现在会区分默认、选择启用和已弃用规则。

    规则更新涉及声明排序、自动闭包检测、更多 ExpressibleByXLiteral 类型、可选绑定、URL 宏、Swift Testing 名称、泛型扩展,以及编译器生成的 Equatable 和 Hashable 一致性。修复涵盖闭包、条件语句、泛型、模块选择器、缩进等格式化边缘问题,也涉及多项规则和选项。Linux 发布构建现在使用 1 MB 堆栈。

    来源:SwiftFormat 0.63.0 发布说明

  11. 0.62.1

    展开

    OpenNavo 编辑 Homebrew 收录

    多个规则现在默认禁用。`noGuardInTests` 新增一个选项,SwiftFormat 也有了包含规则文档的新网站。

    规则
    默认禁用:isEmpty、preferContains、preferFirstWhere。同样默认禁用:preferCountWhere、preferMinOverSorted、preferFlatMap。
    选项
    noGuardInTests 新增 --guard-like-if-statements;默认值:preserve。
    网站
    新网站:swiftformat.info,提供规则文档。

    SwiftFormat 0.62.1 将多个规则设为默认禁用:isEmpty、preferContains、preferFirstWhere、preferCountWhere、preferMinOverSorted 和 preferFlatMap。

    noGuardInTests 规则新增 --guard-like-if-statements 选项,默认值为 preserve。

    SwiftFormat 还推出了新网站 swiftformat.info,规则文档可在 swiftformat.info/rules 查看。

  12. 0.62.0

    展开

    GitHub Release Homebrew 收录

    SwiftFormat new has a website: swiftformat.info! Rules documentation is now available at swiftformat.info/rules.

    • Added redundantSwiftUIGroup rule
    • Added preferContains rule
    • Added preferMinOverSorted rule
    • Added preferFlatMap rule
    • Added preferFirstWhere rule
    • Enabled isEmpty rule by default
    • Split wrapConditionalBodies rule into wrapIfStatementBodies, wrapIfExpressionBodies, wrapGuardStatementBodies
    • Added --indent-blank-lines option to match the surrounding context
    • Added --line-wrap-threshold option for length-based wrapping
    • Added --type-blank-lines consistent option
    • Added start-only and end-only values to --type-blank-lines
    • Added before-non-local-declarations value for --doc-comments
    • Updated noGuardInTests rule to apply to guard-like if statements, use try #require for boolean conditions
    • Updated redundantSendable rule to be disabled by default, and to skip enums with indirect cases
    • Fixed redundantVariable incorrectly removing variables with modifiers or attributes
    • Fixed preferSwiftTesting spuriously adding UIKit import for UInt types
    • Fixed $name closure parameters incorrectly treated as unused when self has a same-named property
    • Fixed docComments rule incorrectly converting enum case group comments to doc comments
    • Fixed markTypes incorrectly considering top-level macro declarations
    • Fixed blankLinesBetweenScopes incorrectly inserting blank line before #elseif directives
    • Fixed emptyExtensions incorrectly removing extensions containing a freestanding macro declaration
    • Fixed organizeDeclarations incorrectly placing freestanding macro declarations after MARK comments
    • Fixed false positive redundantSendable for indirect enum
    • Fixed spaceAroundParens incorrectly inserting space before Optional.some(...) in subsequent @Test arguments
  13. 0.61.1

    展开

    GitHub Release Homebrew 收录

    • Fixed race condition when parsing config files
    • Fixed redundantStaticSelf false positive inside closures and nested functions
    • Fixed unsafe keyword dot-spacing edge case
    • Fixed redundantSelf crash on switch expression inside if-let binding chain
    • Fixed redundantEquatable removing manual == for types with Any.Type stored properties
  14. 0.61.0

    展开

    GitHub Release Homebrew 收录

    • Added wrapCaseBodies rule
    • Added redundantEmptyView rule
    • Added preferSwiftStringAPI rule
    • Added --test-case-access-control option for testSuiteAccessControl rule
    • Updated sortImports to support --import-grouping length,alpha
    • Updated --self-required to support assignment type names like OSLogMessage
    • Updated --suite-name-format default value to preserve
    • Fixed conditional import parsing with access modifiers
    • Fixed infinite loop in organizeDeclarations when opening brace has a trailing comment
    • Fixed closing brace indentation with --trimwhitespace nonblank-lines
    • Fixed indentation of multiline raw string literals with --indent-strings
    • Fixed redundantParens incorrectly removing () from @MainActor closure signatures
    • Fixed wrapping inside parens of function declarations with no parameters
    • Fixed extensionAccessControl incorrectly hoisting public onto extensions of nested internal types
    • Fixed spaceAroundParens incorrectly removing space after nonisolated(nonsending) modifier
    • Fixed noGuardInTests incorrectly transforming guard #available conditions
    • Fixed trailing comma for @convention closures
    • Fixed number handling in Swift Testing test case name conversion
    • Fixed redundantSelf inserting self. inside #if/#elseif compiler directive conditions
  15. 0.60.1

    展开

    GitHub Release Homebrew 收录

    • Fixed issue where redundantSendable rule would unexpectedly remove Sendable conformance on type defined in public extension
    • Fixed issue where redundantSendable rule would leave behind extra space when removing :
    • Renamed redundantProperty rule to redundantVariable
    • Updated redundantVariable rule to preserve variables with explicit type annotations
    • Updated enumNamespaces rule to preserve Swift Testing suites as structs
  16. 0.60.0

    展开

    GitHub Release Homebrew 收录

    • Added redundantSwiftTestingSuite rule
    • Added redundantSendable rule
    • Added preferExpicitFalse rule
    • Added support for :: module selector syntax
    • Added support for value generics syntax
    • Updated swiftTestingTestCaseNames to use raw identifiers by default
    • Updated swiftTestingTestCaseNames to use UpperCamelCase for test suite names
    • Updated redundantSelf to handle guard statements
    • Updated unusedArguments to handle for loop variables
    • Updated redundantType to better handle Set literals
    • Updated redundantParents to remove empty parens from attributes
    • Updated sortImports to sort imports by access control
    • Updated blankLinesBetweenImports to preserve indentation when indent disabled
    • Updated unusedPrivateDeclaration rule to preserve private @Test functions
    • Updated preferSwiftTesting rule to convert tests in extensions within the same file
    • Updated --stdin-path to not require the file to actually exist
    • Updated simplifyGenericConstraints to avoid adding duplicate constraints
    • Updated blankLinesAroundMark to insert blank line before MARK at start of scope when allowed by blankLinesAtStartOfScope config
    • Updated redundantEquatable to preserve == implementation in types with Strideable conformance
    • Fixed handling of switch statements with #if blocks in several rules
    • Fixed issue where async function declarations were wrapped using wrapArguments instead of wrapParameters
    • Fixed issue where redudantViewBuilder would remove @ViewBuilder from protocol members
    • Fixed redundantSelf parsing issue with throwing closure return types and switch expressions in if let condition
    • Fixed trailingCommas rule incorrectly adding commas to if #available checks
    • Fixed guard...else indentation in wrapArguments with wrap-conditions
    • Fixed issue where simplifyGenericConstraints would leave dangling where keyword in protocol members
    • Fixed issue where trailingCommas didn't handle closure capture lists with macro expressions
    • Fixed indentation for closure parameters on separate lines
    • Fixed issue where .init would be removed in code like [Foo].init { ... } (not supported until Swift 6.4).
    • Fixed issue where .swift-version files were read from excluded directories
    • Fixed incorrect replacement of && operator with , inside a ternary condition
    • Fixed unusedArguments bug in code with try? await
    • Fixed handling of MainActor attributes in redundantViewBuilder
  17. 0.59.1

    展开

    GitHub Release Homebrew 收录

    • Reverted changes to indent rule --ifdef handling from 0.59.0
    • Updated docComments rule to use doc comments on nested functions and handle conditional compilation blocks in function bodies
    • Updated spaceAroundBrackets to preserve space between global actor attribute and closure capture list
    • Updated redundantMemberwiseInit to preserve inits with attributes
    • Fixed handling of any keyword in sortTypealiases rule
    • Resolved build issue related to macOS 13 SDK availability
  18. 0.59.0

    展开

    GitHub Release Homebrew 收录

    • Added simplifyGenericConstraints rule
    • Added validateTestCases rule
    • Added testSuiteAccessControl rule
    • Added wrapPropertyBodies rule
    • Added wrapFunctionBodies rule
    • Added redundantViewBuilder rule
    • Added --ifdef preserve option to indent rule
    • Added --prefer-synthesized-init-for-internal-structs option to redundantMemberwiseInit rule
    • Enabled more rules by default: blankLinesBetweenImports, docComments, emptyExtensions, environmentEntry, noForceTryInTests, noForceUnwrapInTests, redundantAsync, redundantEquatable, redundantMemberwiseInit, redundantProperty, redundantThrows
    • Updated typeSugar to only preserve explicit Optional<T> in structs with a synthesized memberwise initializer
    • Updated closing paren of single-argument functions and collections to wrap if needed
    • Updated redundantMemberwiseInit rule to support result builder attributes
    • Improved how organizeDeclarations handles structs with a synthesized memberwise initializer
    • Updated docComments rule to preserve formatting of comments with directives
    • Fixed --ifdef no-indent handling of method chains and nested directives
    • Fixed issue where XMLReporter did not properly escape strings
    • Fixed support for unsafe keyword
    • Fixed edge cases in spaceAroundBrackets rule
    • Fixed crash in sortTypealiases rule
    • Fixed issue where redundantSelf rule could crash if encountering a function with no body (e.g.@_silgen_name)
  19. 0.58.7

    展开

    GitHub Release Homebrew 收录

    • Fixed redundantSelf not being applied inside if #available(...) { ... } clauses
    • Fixed fileHeader rule incorrectly setting creation year to current when file path contains spaces
    • Fixed mis-insertion for nil-init rule related to optional closure return values
    • Fixed unusedPrivateDeclarations false positive when call site was outside enabled range
    • Fixed sortImports rule incorrectly moving // swift-tools-version: comment directive
    • Fixed hoistTry rule sometimes producing mangled code when hoisting across line boundaries
    • Fixed crash in --ruleinfo command when rule options exceed the old max length requirement
    • Fixed crash in unusedArguments due to scope range bug
  20. 0.58.6

    展开

    GitHub Release Homebrew 收录

    • Fixed docComments not being applied correctly after conditional switch...case
    • Trailing commas are no longer inserted inside #selector(...) expressions
    • Source files listed with --filelist are now formatted concurrently
    • Trailing comments are now kept with the same line when wrapping
    • Fixed spurious return removal inside repeat...while loops
    • Fixed bug with trailingClosures rule and property wrappers
    • Fixed performance regression introduced in 0.58.5
    • Reduced timeout threshold to 1ms per token
  21. 0.58.5

    展开

    GitHub Release Homebrew 收录

    • Fixed regression with indenting of macros (introduced in 0.58.4)
    • Fixed spurious removal of return keyword inside for ... where loops
    • Fixed parsing error with for await case ... loops
    • Added XCTUnwrap to the default exclusion list for hoistTry
  22. 0.58.4

    展开

    GitHub Release Homebrew 收录

    • Whitespace is no longer added or removed from blank lines in multiline string literals
    • Fixed trailingComma rule incorrectly inserting commas inside typed throws
    • Fixed issue where opaqueGenericParameters rule could cause build errors with existential types
    • Fixed false positive with unusedArguments when argument is only referenced inside a macro
    • The noGuardInTests rule now preserves custom failure messages
    • The noGuardInTests rule no longer adds throws to test methods when not needed
    • Removed redundant "default" values from options help descriptions
  23. 0.58.3

    展开

    GitHub Release Homebrew 收录

    • Fixed parsing of [n of X] syntax for InlineArray in Swift 6.2
    • Fixed parsing error when an opening multiline string delimiter is followed by a space
    • Fixed issue where redundantInit rule could leave orphaned parentheses
    • Fixed bug where redundantInit was incorrectly applied to (Foo.self as Bar.Type) expressions
    • Fixed bug with parsing empty property accessors that broke redundantSelf rule
    • Fixed aliasing issue with acronyms rule where one acronym overlaps another
    • Fixed unexpected wrapping of closing parenthesis in wrapArguments rule
    • Added --unknown-rules option to support environments with older SwiftFormat versions
  24. 0.58.2

    展开

    GitHub Release Homebrew 收录

    • Fixed issue where modifierOrder rule confused async effect for async modifier
    • Fixed issue where testing related rules incorrectly treated functions with arguments as test cases
    • Updated redundantInit rule to apply to init calls with single trailing closure
    • Updated README.md to reflect actual precedence behavior between .swift-version files and --swift-version arguments