SwiftSyntax parser library isn't compatible

Using commit: 94482c3e79f97e78575906da55f02e1c04f8e531
Xcode Version: 11.2.1
Swift Version: 5.1.2

1. git clone GitHub - apple/swift-format: Formatting technology for Swift source code
2. cd swift-format
3. swift build -c release
4. execute the command ./.build/release/swift-format -i ~/Desktop/Test.swift

Raise Exception: SwiftSyntax parser library isn't compatible

You need to check out the swift-5.1-branch of swift-format if you're using it alongside Swift 5.1.x. master is currently pinned to a development snapshot (unfortunately an older one, but still past where the 5.1.x releases were cut). See Matching swift-format to Your Swift Version in the README for more info.

In the near future, we're going to keep master in sync with the master branches of swift-syntax and swift, so the release branch scheme will still apply.

How can I make swift-format work with Xcode 11.4 ?
For the moment I have this issue SwiftSyntax parser library isn't compatible.
Should @akyrtzi tag swift-syntax since Xcode 11.4 is getting ready to ship ?

Sorry, the parser library from beta 1 is out-of-sync with what is currently in the swift-5.2-branch, we are looking into getting them in-sync.
In the meantime try using the matching OSS toolchain from the SwiftSyntax tag that swift-format uses.

Created an issue Apple Swift-Format tool for Xcode 11.4 - Stack Overflow

Xcode 11.4 is compatible with the swift-5.2-branch of SwiftSyntax, or the 0.50200.0 tag. SwiftFormat currently uses the swift-DEVELOPMENT-SNAPSHOT-2020-01-29-a tag. The snapshot tags are only guaranteed to be compatible with the Swift toolchain of the same tag.

@allevato would it be possible to update SwiftFormat's dependency tag to be the 0.50200.0 one?

swift-5.1-branch does not compiles with 0.50200.0` tag. with errors

/swift-format/Sources/SwiftFormatCore/Trivia+Convenience.swift:76:16: error: type 'TriviaPiece' has no member 'backticks'

if case .backticks = piece { return true }


/swift-format/Sources/SwiftFormatCore/Trivia+Convenience.swift:188:14: error: type 'TriviaPiece' has no member 'backticks'

case (.backticks(let l), .backticks(let r)):

Update to Swift 5.2 release. by allevato ¡ Pull Request #163 ¡ apple/swift-format ¡ GitHub is out for review. Once merged, I'll cut a swift-5.2-branch that will be guaranteed to remain compatible with Swift 5.2's version of the syntax parser.

The Swift version in the swift-format branch name indicates the exact version of swift-syntax and the syntax parser that that branch is compatible with. There are no guarantees of compatibility (and in fact, no likelihood of it) if the swift-format branch and swift-syntax release are mismatched.

I've just cut the swift-5.2-branch on swift-format that is compatible with the syntax parser in Xcode 11.4.

I'm getting this same message, but I'm using Xcode 12.0 Beta 6 and Swift 5.3, and I installed the app using "brew install swiftdocorg/formulae/swift-doc". I just now tried every variation I could think of with "swift doc generate ./Source --module-name Grid" (yes, I have a folder called "Source" that has Swift code in it). But everything I tried gave me "Error: SwiftSyntax parser library isn't compatible". Any ideas? Cheers

Probably swift‐doc depends on a fixed version of swift‐syntax and needs the matching toolchain around to run. (The parser library is in the toolchain; not the product folder of a package build.) I don’t know what release of swift‐doc homebrew may have used, but its master branch appears to depend on 0.50200.0. If the release is the same, then the necessary toolchain is 5.2. (It doesn’t matter which patch number you choose; all patches of 5.2 happen to be mutually compatible.)

Thanks much. Is there a brew fix-this-mess kind of command I can use? I see an option --with-toolchain in homebrew, but it seems like people point it to LLVM, which means I know less than nothing about the problem and in a few hours I'll be wiping my storage and reinstalling macOS. If there's not some easy way to do this, could you give me an idea of where to start learning about it? Cheers

You should just need Xcode 11.7 and use that toolchain.

Now I'm really worried. Do you mean I'll need to go back to Xcode 11.7 to use swift doc? I'm using 12.0. Thanks

@Jon_Shier -- now I get it. Install swift doc using the 11.7 toolchain. Thanks again

Just out of mind-blown curiosity, does this situation suggest that no one has installed swift doc using Homebrew since at least Xcode 11.7?

Xcode 11.7 is newer than the last Xcode 12 beta. Support for beta Xcodes shouldn’t be expected.

Just to clarify for future readers (since I was confused at first, since this and the post it's replying to were in this thread in the swift-format subforum), swift-doc doesn't appear to depend on swift-format; the issue is the dependency from swift-doc to swift-syntax.

That being said, I do need to cut a 5.3 compatible branch for swift-format soon, now that we're this far into the release cycle. The master branch is aligned with apple/swift master and is already incompatible with 5.3 since it has additions like async/await.

1 Like

Sorry. I wrote the first sentence before I even knew what swift‐doc was. Then I decided to try to find it to take a closer look. When I came back with more information, I just kept writing and failed to notice that the two halves of the post ended up incongruous.

I have fixed the post, but I cannot split the thread to move it to the swift‐syntax section where it belongs.

1 Like

I was able to build Xcode 12 compatible version like this:

  1. This is the revision of swift-format compatible with Swift 5.3
    GitHub - apple/swift-format at 35fdb4fff0aeb9a506fccdfad98fab16d907c173
  2. In Package.swift SwiftSyntax has to be pinned to Swift 5.3 tag
    .package(url: "https://github.com/apple/swift-syntax", .revision("swift-5.3-RELEASE")),
  1. swift build -c release

The binary will be in .build/release folder. Though there are some deprecation warnings during the build, it works just fine.

1 Like