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<
I met this problem in a project where dependency is managed by Carthage. In my case, I didn't set command line tool in xcode (Type in xcodebuild -version, you will know whether you set it up or not), so first step is to go to XCode --> Preference --> Locations then select the xcode you want to serve as command line tool. Then you can follow the steps that @Domsware mentioned above to rebuild all frameworks you are gonna use.
===============================================
Same problem here but using Carthage. And here is the answer:
rm -rf ~/Library/Caches/org.carthage.CarthageKit/DerivedData
delete the Carthage folder for the project
Update Carthage: carthage update --platform iOS
===============================================
Then don't forget to delete old links under 'Linked frameworks and libraries' and drag all frameworks from /Carthage folder under you project to 'Linked frameworks and libraries'.
Then voilà!
For those who are using CocoaPods, I suspect (Disclaimer: I didn't encounter this problem in project where CocoaPods is the dependency manager) the solution would be run the following command in terminal:
$ pod deintegrate
$ pod clean
$ pod install
where you might need to install 'deintegrate' and 'clean' tool for CocoaPod
$ sudo gem install cocoapods-deintegrate cocoapods-clean
more details see post How to remove CocoaPods from a project?