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.