Repository navigation
yarn format-swift skips formatting with Xcode 27.1, whose swift-format reports its version as main #59598
Description
Description
scripts/format-swift.js keeps a swift-format only when its --version output parses as 6.3 or newer: parseSwiftFormatVersion (L49-L61) reads swift-format <major>.<minor>, Swift version <major>.<minor> or a bare <major>.<minor>. The swift-format in Xcode 27.1 (Swift 6.4) prints main for both swift format --version and xcrun swift-format --version, so the script finds no formatter, prints its "Skipping Swift formatting" warning and exits 0. yarn format-swift, yarn format-check-swift and yarn format then pass without formatting or checking any Swift file.
Steps to reproduce
On macOS with Xcode 27.1, at main c12d0b3:
swift format --version. Expected: a version. Seen:main.node scripts/format-swift.js --check. Expected: swift-format checks the repository's Swift files. Seen: the warning below, then exit 0.
React Native Version
main (c12d0b3)
Affected Platforms
Build - MacOS
Output of npx @react-native-community/cli info
Not applicable: this is the repository's own scripts/format-swift.js.
Stacktrace or Logs
macOS 27.0.1, Node 26.12.1:
$ xcodebuild -version
Xcode 27.1
Build version 27A9275
$ swift --version
swift-driver version: 1.168.6 Apple Swift version 6.4 (swiftlang-6.4.0.34.1 clang-2100.3.34.1)
$ swift format --version
main
$ xcrun swift-format --version
main
$ node scripts/format-swift.js --check
warning: Skipping Swift formatting because swift-format 6.3 or newer was not found.
Please install Swift 6.3 or newer and make sure `swift-format` or `swift` is in your PATH, or set SWIFT_FORMAT=/path/to/swift-format.
exit 0
MANDATORY Reproducer
The repository's own script on main:
react-native/scripts/format-swift.js
Lines 49 to 61 in c12d0b3
| function parseSwiftFormatVersion(output) { | |
| const version = | |
| /swift-format(?: version)?[:\s]+(\d+)\.(\d+)/i.exec(output) ?? | |
| /Swift version\s+(\d+)\.(\d+)/i.exec(output) ?? | |
| /^\s*(\d+)\.(\d+)/.exec(output); | |
| if (version == null) { | |
| return null; | |
| } | |
| const reportedMajor = Number(version[1]); | |
| return reportedMajor >= 100 | |
| ? [Math.floor(reportedMajor / 100), reportedMajor % 100] | |
| : [reportedMajor, Number(version[2])]; | |
| } |
Screenshots and Videos
No response
Activity
react-native-bot commentedon Oct 29, 2026
Warning
Missing reproducer: We could not detect a reproducible example in your issue report. Reproducers are mandatory and we can accept only one of those as a valid reproducer:
You can read more about about it on our website: How to report a bug.
YevheniiKotyrlo commentedon Oct 29, 2026
The reproducer is the repository's own
scripts/format-swift.jsonmain, which reads the version this way since #58463: the body has the commands and their output with Xcode 27.1.Fix Swift formatter detection when version is main