Module compiled with swift 4.0 cannot be imported in swift 3.1

user8118543 picture user8118543 · Jun 10, 2017 · Viewed 15.6k times · Source

Apparently I have managed to build my project in Xcode 9 beta and now I only get the error

Module compiled with swift 4.0 cannot be imported in swift 3.1

When I run the project in Xcode 8. The module in my case are Alamofire. I have tried to restart Xcode but nothing happens any ideas how to solve this issue?

Answer

Rashwan L picture Rashwan L · Jun 10, 2017

You have two options that you can do:

Clean the project and then try to re-build your solution and see if it works.

If it don´t work and you still get the same error message then do the following steps and it should work for you:

  1. Open your podfile and remove Alamofire
  2. Run pod update
  3. Re-add Alamofire to your podfile
  4. Run pod update
  5. When this is done, clean your project and run it