27

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.

7
  • Change Use Legacy Swift Language Version to NO. That will let you use swift 3 compiled modules. Commented Sep 21, 2016 at 12:45
  • Change for what target? For both? Commented Sep 21, 2016 at 12:46
  • Try changing it for both. From what I understand you should only enable it if you want to use SWIFT 2.3 Commented Sep 21, 2016 at 12:47
  • @EugenDimboiu Ok, I changed it like you said, but... when I type pod spec lint BSTableViewReorder.podspec I got The spec did not pass validation, due to 49 errors and 6 warnings.. You know what is wrong? My project successfully compiles on iphone and works. Commented Sep 21, 2016 at 12:58
  • Can you post your Podfile? are you sure you're targeting IOS and swift 3 in the podfile ? Commented Sep 21, 2016 at 13:05

4 Answers 4

27
+200

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.

Sign up to request clarification or add additional context in comments.

Comments

0

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.

Comments

0

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.

Comments

0

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.