Mahdi Moqadasi
Mahdi Moqadasi

Reputation: 2479

Swift Version Conflict: this SDK is not supported by the compiler, Please select a toolchain which matches the SDK

I'm using xCode 13.1 with macOS 12.0.1 Monterey. I added KingFisher and removed it from my pod. but my project is not built anymore. I got this error for one of my local SDKs:

Failed to build module 'CbSdk';
this SDK is not supported by the compiler (the SDK is built with 'Apple Swift version 5.4
(swiftlang-1205.0.26.9 clang-1205.0.19.55)', while this compiler is 'Apple Swift version 5.5.1 
(swiftlang-1300.0.31.4 clang-1300.0.29.6)'). Please select a toolchain which matches the SDK.

What I've done but didn't work:

Upvotes: 31

Views: 43051

Answers (3)

Zachary Buresh
Zachary Buresh

Reputation: 41

In my case, I'm developing a Framework that uses 3rd party Swift Packages internally. Originally, I thought this error was being thrown because I upgraded to Xcode 15. Turns out, it was completely unrelated.

If you are using 3rd party libraries and want to export a Framework, you must include the "@_implementationOnly" tag in front of the imports.

Example: "@_implementationOnly import BoltsSwift".

If you do this, it will not include these 3rd party library imports in the binary modules within the framework. This is great because the users of your framework don't care about the 3rd party libraries used in the back-end. Hope this helps at least one person! I rarely see anything online about the @_implementationOnly tag.

Upvotes: 4

Md Imran Choudhury
Md Imran Choudhury

Reputation: 9997

I fetch the same problem when I try to update a library. My Xcode version was 13.2 with the swift version5.5.2. But the library I want to update required a swift version of 5.7.0. Using toolchains in Xcode might be the solution but I decided to update the Xcode version with the latest.

I update my Xcode to the latest version 14.1 and the issue is resolved. Automatically the swift version is found on the latest Xcode.

Upvotes: 4

Pawan Sharma
Pawan Sharma

Reputation: 3334

Taken from this Twitter thread.

You need to set the BUILD_LIBRARY_FOR_DISTRIBUTION build setting on the framework target

https://www.swift.org/blog/library-evolution/

https://developer.apple.com/videos/play/wwdc2019/416/

enter image description here

Upvotes: 12

Related Questions