Why does Xcode say library compiled with command line tools is the wrong version swift?

So, I'm using Carthage - my first project, I usually use CocoaPods (not my choice). I'm trying to build this app using XCode11. I set the toolset in XCode 11 (Preferences -> Locations) to the 10.2 toolset. The project is set to Swift5.


When I run carthage (see below), everything builds fine. No errors or anything.


$ carthage update --platform iOS --no-use-binaries

But in XCode, when I try to build the app, it complains the libraries are the wrong version. But, isn't the XCode IDE using the same tools as the CLI builds?

>>Module compiled with Swift 5.0 cannot be imported by the Swift 5.1 compiler


It shows this error on the line "import Alamofire" - how is this happening?

In the terminal, I run "xcodebuild --version" and i get this:

Xcode 10.2

Build version 10E125


Which is what I set in XCode (Preferences -> Locations) as I said above.
What is going on here? Why is the CLI build using Swift version 5.0 but XCode is (appears to be) using Swift 5.1 - how can that be if the same toolset is selected?
Help!
Note: I have tried this with Beta 5, the most recent one.

Replies

Your macOS comes with one version Swift... installing Xcode layers another.


I'll see if I can find the last thread where this came up, but if you don't want to wait, feel free to search on your own.

But, isn't the XCode IDE using the same tools as the CLI builds?

Not in general. The Xcode app uses the version built in to that app (unless you’ve set up a custom toolchain). The command line tools use the version selected via

xcode-select
(see its man page for details).

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"