Failed to build module 'MyFrameworkA'; this SDK is not supported by the compiler (original) (raw)

I am importing third party .xcframeworks in a capacitor plugin. I am using the Swift Package Manager to include these frameworks in the following manner in my Package.swift file.

// swift-tools-version: 5.9
import PackageDescription

let package = Package(
    name: "MyPlugin",
    platforms: [.iOS(.v14)],
    products: [
        .library(
            name: "MyPlugin",
            targets: ["MyPlugin"])
    ],
    dependencies: [
        .package(url: "https://github.com/ionic-team/capacitor-swift-pm.git", from: "7.0.0")
    ],
    targets: [
        .target(
            name: "MyPlugin",
            dependencies: [
                .product(name: "Capacitor", package: "capacitor-swift-pm"),
                .product(name: "Cordova", package: "capacitor-swift-pm"),
                "MyFrameworkA",
                "MyFrameworkB"
            ],
            path: "ios/Sources/MyPlugin"),
        .testTarget(
            name: "MyPluginTests",
            dependencies: ["MyPlugin"],
            path: "ios/Tests/MyPluginTests"),
        .binaryTarget(
              name: "MyFrameworkA",
              path: "./ios/Frameworks/MyFrameworkA"),
        .binaryTarget(
            name: "MyFrameworkB",
            path: "./ios/Frameworks/MyFrameworkB")
    ]
)

When I now go into iOS/sources/MyPlugin/My.swift

and I do

import MyFrameworkA

or

@_implementationOnly import MyFrameworkA

then I get this error:

Failed to build module 'MyFrameworkA'; this SDK is not supported by the compiler

(the SDK is built with 'Apple Swift version 5.7.2 (swiftlang-5.7.2.135.5 clang-1400.0.29.51)', while this compiler is 'Apple Swift version 6.1.2 effective-5.10 (swiftlang-6.1.2.1.2 clang-1700.0.13.5)').

Please select a toolchain which matches the SDK.

What can I do against this? Why should this even be an issue that a third party dependency was compiled in slightly different version? I do not even have a .xcproj or .xcworkspace file in my capacitor plugin to define any toolchain / swift lang version.

I am running the latest Xcode 16.4 (16F6)

Same problem for MyFrameworkB but with a slightly different version in the error.

allevato (Tony Allevato) June 16, 2025, 12:16pm 2

Are there any other errors in the build log before that one?

In my experience, the "SDK is built with 'X' while this compiler is 'Y'" is a catch-all error that gets emitted at the end when the compiler fails for some other reason trying to load a textual module interface. Unfortunately that error is sort of misleading (an SDK built for an older compiler should definitely be compatible with a newer compiler, or the whole compatibility story would be broken), but you may need to go scraping the logs more to find the actual error.

The error pops up in 2 places

  1. the editor on the same line as the import
  2. in the Issues tab of the navigator. It is the only error here

This error pops up immediately after writing the import, I did not even press some build button