Skip to content

yarn format-swift skips formatting with Xcode 27.1, whose swift-format reports its version as main #59598

Closed

Description

@YevheniiKotyrlo

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:

  1. swift format --version. Expected: a version. Seen: main.
  2. 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:

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])];
}
, which reads the version this way since #58463 added it

Screenshots and Videos

No response

Activity

  1. react-native-bot commented on Oct 29, 2026

    @react-native-bot
    Collaborator

    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.

  2. YevheniiKotyrlo commented on Oct 29, 2026

    @YevheniiKotyrlo
    ContributorAuthor

    The reproducer is the repository's own scripts/format-swift.js on main, which reads the version this way since #58463: the body has the commands and their output with Xcode 27.1.

  3. added a commit that references this issue on Oct 30, 2026
    ede7ebf
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs: AttentionIssues where the author has responded to feedback.Needs: ReproThis issue could be improved with a clear list of steps to reproduce the issue.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions