Alamofire: Module compiled with Swift 5.1 cannot be imported by the Swift 5.1.2 compiler.

What did you do?

I just updated to the non-beta version of Xcode 11.2. I opened a project I was working on and Xcode threw the error Module compiled with Swift 5.1 cannot be imported by the Swift 5.1.2 compiler. for Alamofire. I’m using Carthage as my package manager.

What did you expect to happen?

Since Swift 5.1, which has module stability, this shouldn’t be happening. Frameworks compiled with Swift 5.1 should work no problem with newer versions of Swift.

What happened instead?

I am getting an error Module compiled with Swift 5.1 cannot be imported by the Swift 5.1.2 compiler. for Alamofire.

Alamofire Environment

Alamofire version: 4.9.1 Xcode version: 11.2 (11B52) Swift version: 5.1.2 Platform(s) running Alamofire: iOS macOS version running Xcode: 10.14.6 (18G103)

Demo Project

To reproduce: run carthage update --platform iOS on a project with Xcode 11.1 and then open the project in Xcode 11.2.

Possible solution

According to this stackoverflow question BUILD_LIBRARY_FOR_DISTRIBUTION = YES; has to be set in Alamofire’s project.pbxproj file.

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 19 (3 by maintainers)

Most upvoted comments

Alamofire will not be enabling module resiliency for actively developed versions due to the rather extreme restrictions it places on the library’s evolution. However, it may make sense to enable it on v4, especially once we release v5. I’ll keep this issue open to ensure we make that release when we release 5.0.0.

Definitely feel this is needed ASAP on v4 versions of Alamofire.

Getting same issue with Xcode 12 Beta 4 Module compiled with Swift 5.2.4 cannot be imported by the Swift 5.3 compiler I tried https://stackoverflow.com/questions/58654714/module-compiled-with-swift-5-1-cannot-be-imported-by-the-swift-5-1-2-compiler (BUILD_LIBRARY_FOR_DISTRIBUTION = YES;) but i didnt work.

Anyone has faced same issue ?

Just noting with Xcode 11.3

Module compiled with Swift 5.1 cannot be imported by the Swift 5.1.3 compiler.

Getting same issue with Xcode 12 Beta 4 Module compiled with Swift 5.2.4 cannot be imported by the Swift 5.3 compiler I tried https://stackoverflow.com/questions/58654714/module-compiled-with-swift-5-1-cannot-be-imported-by-the-swift-5-1-2-compiler (BUILD_LIBRARY_FOR_DISTRIBUTION = YES;) but i didnt work.

Anyone has faced same issue ?

Yes I am also facing the similar issue

What worked for me -

* Switch command-line tools to use the new version of Xcode in your Xcode preferences

* Delete all files in the Carthage folder except the input file

* Run Carthage update.

* Delete derived data of the project

* Clean and Build the project

Hope this helps!

@kinjaldua hello! could you please help me with the steps in more details (I mean how to do this exactly). Because I am the beginner and I am afraid to destroy my project with inexperienced actions.