The loaded '_InternalSwiftSyntaxParser' library is from a toolchain that is not compatible with this version of SwiftSyntax

0

I'm using Xcode12.5 and swift version 5.4. When I try to build my project I get this error: The loaded '_InternalSwiftSyntaxParser' library is from a toolchain that is not compatible with this version of SwiftSyntax.

My Package.swift file:

import PackageDescription

let package = Package(
name: "NeedleFoundation",
products: [
    .library(name: "NeedleFoundation", targets: ["NeedleFoundation"]),
    .library(name: "NeedleFoundationTest", targets: ["NeedleFoundationTest"])
],
dependencies: [],
targets: [
    .target(
        name: "NeedleFoundation",
        dependencies: []),
    .testTarget(
        name: "NeedleFoundationTests",
        dependencies: ["NeedleFoundation"],
        exclude: []),
    .target(
        name: "NeedleFoundationTest",
        dependencies: ["NeedleFoundation"]),
    .testTarget(
        name: "NeedleFoundationTestTests",
        dependencies: ["NeedleFoundationTest"],
        exclude: []),
],
swiftLanguageVersions: [.v5]

)

#if compiler(>=5.4)
package.dependencies += [
    .package(url: "https://github.com/apple/swift-format", .branch("swift-5.4-branch"))
]
#elseif compiler(>=5.3)
package.dependencies += [
    .package(url: "https://github.com/apple/swift-format", .branch("swift-5.3-branch"))
]
#endif

And then I run : swift run swift-format After that when I try to build my project I receive the same error: The loaded '_InternalSwiftSyntaxParser' library is from a toolchain that is not compatible with this version of SwiftSyntax.

How can I fix it?