9

Swift 4.0 modules were fine in Swift 3.2 apps with Xcode 9.0.

But now, with Xcode 9.1, I get:

Module compiled with Swift 4.0 cannot be imported in Swift 3.2.1

Or:

Module compiled with Swift 4.0 cannot be imported in Swift 4.0.1

Cœur
  • 37,241
  • 25
  • 195
  • 267
  • I had this error message, too, and it turned out to be caused various syntax errors in my code. Once I fixed the syntax errors, the error went away. – piccy Nov 06 '17 at 17:00

3 Answers3

10

Swift 4.0 is compatible with Swift 3.2 only.
Swift 4.0.1 is compatible with Swift 3.2.1 only.

So:

  • you can't mix 4.0 and 3.2.1
  • you can't mix 4.0.1 and 3.2
  • you can't mix 4.0 and 4.0.1
  • you can't mix 3.2.1 and 3.2

To formulate it differently:

  • you can mix Xcode 9.0 supported Swift versions together
  • you can mix Xcode 9.1 supported Swift versions together
  • you can't mix Xcode 9.0 and Xcode 9.1 Swift versions

If the module was built by you, simply rebuild it with the same Xcode.
If the module was built by a third party, request an Xcode 9.1 compatible build.

Cœur
  • 37,241
  • 25
  • 195
  • 267
7

It's possible to build using Swift 3.2 in Xcode 9.1 beta 2 by installing the Xcode 9.0 toolchain and using that to build your project.

Swift Toolchain Image

Then choose the Swift 4.0 release under the Xcode -> Toolchains menu.

You should now be able to build with either Swift 3.2 or 4.0 in Xcode 9.1 b2.

JRG-Developer
  • 12,454
  • 8
  • 55
  • 81
Hung Truong
  • 91
  • 1
  • 2
  • Oh, correct... but then at the time of stable Xcode 9.1, custom toolchain won't be accepted by iTunes Connect for release. – Cœur Oct 12 '17 at 02:03
  • That's true. I suppose you could always continue to submit using Xcode 9.0 while testing on Xcode 9.1 beta. Sort of annoying that some of the iPhone X functionality is not working in the current Xcode though. – Hung Truong Oct 12 '17 at 05:44
0

Using the last Xcode version solved this issue

Sob7y
  • 17
  • 5