Xcode 9 : Module compiled with Swift 3.1 cannot be imported in Swift 4.0

Arnaud picture Arnaud · Jun 6, 2017 · Viewed 36.6k times · Source

After updating to Xcode 9, I tried to build one of my projects.

I use the FacebookLogin pod. I have a compiler error in FacebookLogin/LoginButton.swift

@testable import FacebookCore
❌ Module compiled with Swift 3.1 cannot be imported in Swift 4.0

In my target's build settings, the Swift language version is set to Swift 3.2.

Screenshot added

I guess I need to wait for Facebook to update their pod ? Or any other suggestion ?

Thanks !

Answer

xavi.pedrals picture xavi.pedrals · Aug 1, 2017

Update:

Solution also tested and working in Swift 5 and Xcode 11.

Original:

I would like to add that if you are using Carthage to compile a module in Swift 3.2 you should go to a terminal and run:

sudo xcode-select --switch /Applications/Xcode-beta.app/Contents/Developer

To use the Xcode 9 command line tools, then you can run:

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

This will compile the library with your current command line tools, it can be a bit slow but now the project should build.

Note

To revert and use your stable Xcode command line tools simply run:

sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer