Module Compiled with Swift 4.0 Cannot Be Imported in Swift 4.0.1

Module compiled with Swift 4.0 cannot be imported in Swift 4.0.1

Update:

For release versions of Xcode:

This error (and similar errors involving Swift 4.1, 4.2, etc.) will occur when opening a project with Xcode 9.1, 9.2, 9.3, 9.4, 10, etc. that uses frameworks that were built with earlier Xcode tools.

To fix the issue, update and rebuild your frameworks using Carthage ( carthage update --platform iOS), Cocoapods (pod update or pod install), or manually, with the new updated Xcode tools. The tools should be updated automatically when you update Xcode, but if not, you can follow the steps outlined below in the original answer.

You may also need to clean your project cmd + shift + k and possibly your build folder cmd + option + shift + k to get Xcode to not use cached framework builds.

In some cases you may also need to delete your derived data folder (Easily found by going to Xcode Preferences -> Locations -> Derived Data Folder
(Thanks Stunner)

For beta versions of Xcode:

See original answer below and then follow steps above.

Original Answer:

You probably still have your xcodebuild tools set to Xcode 9.0 which builds with Swift 4.0 and is incompatible with Xcode 9.1 beta's Swift 4.0.1.

Check in the terminal using the command:

xcodebuild -version

Or just go into Xcode preferences -> Locations and check/change the command line tools to Xcode 9.1. You should be set then.

Module compiled with Swift 4.0 cannot be imported in Swift 3.2.1

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.

Adding framework manually - Module compiled with swift 4.0 cannot be imported in Swift 4.0.3

You need to recompile the framework with swift 4.0.3 before adding it to your project.

Module compiled with Swift 4.2.1 cannot be imported by the Swift 5.0 compiler

The correct solution is download Xcode 10.1, and wait for Apple patch the bug fix.

Don't waste time on fix third-party bug.


The problem of my project is we are using Alamofire which is failed to update by Carthage.



Related Topics



Leave a reply



Submit