Search code examples
swiftxcoderealm

Module compiled with Swift 4.0 cannot be imported in Swift 3.2.2 - After XCode 9.1


I have been using a Realm for a while now without a problem until today when XCode self-auto-upgraded to XCode 9.1. I open my project and I get the following error.

Module compiled with Swift 4.0 cannot be imported in Swift 3.2.2: /Users/UserName/MyApp/MyApp Watch App Extension/RealmSwift.framework/Modules/RealmSwift.swiftmodule/i386.swiftmodule

The error points to the import RealmSwift

I tried upgrading to Realm version swift-4.0 but I keep getting the same error. The way I upgraded was by deleting the Realm frameworks from my project and adding version swift-4.0.

FYI - I'm not using Swift 4 in my project.

Any idea what could be wrong?


Solution

  • The error message is telling you that Xcode 9.1 is using Swift 3.2.2, while the Realm Swift framework you're building against was built for Swift 4.0 (using Xcode 9.0). You need to update your Realm frameworks to versions built for the version of Swift that you're using, which you can find in the most recent release of Realm.