Search code examples
iosswiftxcoderealmcarthage

Module file was created by a newer version of the compiler


I'm taking over development of a project and am unable to contact the previous developer. I'm trying to figure out which versions of the imbedded open source libraries were used. The project appears to be in Swift 2.1. I am attempting to compile it with Xcode 7.3.1. Carthage was the package manager used. I'm stuck on an error with RealmSwift. The error occurs on the line that tries to import RealmSwift.

/{app source path}/PersonnelModel.swift:10:8: Module file was created by a newer version of the compiler: /{app source path}/Carthage/Build/iOS/RealmSwift.framework/Modules/RealmSwift.swiftmodule/x86_64.swiftmodule

I have worked my way all the way back to version 0.96.2 of realm-cocoa, which I believe is the first version to support Xcode 7.1 and Swift 2.1. However, I'm still getting the error.

I have looked through other answers on here, but have not found a solution that works. Am I misunderstanding the cause of the error? I just thought it was picking up a newer version of the framework.

Here is what my Cartfile looks like:

github "ReactiveCocoa/ReactiveCocoa"
github "Alamofire/Alamofire" ~> 3.4
github "SwiftyJSON/SwiftyJSON"
github "realm/realm-cocoa" == 0.96.2
github "scalessec/Toast-Swift" ~> 1.4.0

Solution

  • If you're just trying to get a clean compile for now, it might be worth taking Realm out of Carthage, installing it manually as a dynamic framework, and then putting it back into Carthage at the end once you've got everything smoothed out.

    Xcode 7.3.1 was Swift 2.2. The very latest version of Realm to support Swift 2.2 is version 2.3.0, so I'd recommend downloading that version and manually importing it into Xcode 7.3.1

    As an aside, Realm has dropped support for Swift 2 starting with version 2.4.0, so it's greatly recommended you migrate your codebase to Swift 3 as soon as possible. :)