Bartłomiej Semańczyk
Bartłomiej Semańczyk

Reputation: 61850

Module compiled with Swift 3.0 cannot be imported in Swift 2.3

This is what I do:

import BSTableViewReorder

and get the following error:

Module compiled with Swift 3.0 cannot be imported in Swift 2.3

What can I do to make it compile? I did:

Edit > Convert -> Current Swift Syntax

Using Xcode 8 and macOS Sierra.

For Both: the target and the project I have the following settings of Use Legacy Swift Language Version

enter image description here enter image description here

The project is my pod for cocoapods dependencies. I just converted project to Swift 3.0 but it does not compile.

Upvotes: 27

Views: 14571

Answers (4)

mtc
mtc

Reputation: 89

If the above suggestions don't work for you try deleting ~Library/Developer/Xcode/DerivedData

Upvotes: 0

shoe
shoe

Reputation: 1080

in my case, the framework developers added this line in the code that was intended for the Podfile:

config.build_settings['SWIFT_VERSION'] = '2.3' # or '3.0'

as you can see, they defaulted to '2.3', which caused problems because i was running 3.0. simply removing the '2.3' # or and leaving the '3.0' fixed the problem.

Upvotes: 0

Payal
Payal

Reputation: 116

If you are using any third party frameworks just update them once for Xcode 8.1 and change the Use Legacy Swift Language Version to NO.

Upvotes: 0

Eugen Dimboiu
Eugen Dimboiu

Reputation: 2803

You'll need to change the Use Legacy Swift Language Version to NO - this makes sure your project will use swift 3.

If you want to package your project as a POD (for cocoapods) you'll need to add a file named .swift-version (containing 1 single line, "3.0"). This will tell cocoapods to use the swift 3 compiler.

Everything should work after this changes.

Upvotes: 27

Related Questions