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

Viewed 358

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.

Am I missing something?

1 Answers

From my research so far on this same problem, the issue is that whatever swift tool you are running (swift-format in this case) depends in the SwiftSyntax package and is not compatible with whatever version of Xcode (toolchain) you are using. You likely need to downgrade the version of Xcode you are using/the tool looks for. Still not sure what the best way to do that is though.

Related