Christian Ettelt
Christian Ettelt

Reputation: 107

Realm's Swift module compiled with Swift 4.0 cannot be imported in Swift 4.0.2

I just updated to XCode 9.1 and when trying to compile my project which was running before under XCode 9.0.1 and Realm 3.0.0, I get the error message 'Module compiled with Swift 4.0 cannot be imported in Swift 4.0.2' at the Realm import in my code

import RealmSwift

I have: - updated to Realm 3.0.1 - Reinstalled the Framework into my project - Cleaned the project with the function in XCode

In the Realm 3.0.1 package there is no Swift-4.0.2 folder, only Swift-4.0.

Should Realm 3.0.1 be compatible to Xcode 9.1? If so, what can I do to make it work? If not, is a new version being created?

Thanks for help.

Regards Christian

Upvotes: 2

Views: 2184

Answers (2)

ambientlight
ambientlight

Reputation: 7332

Swift 4.0.2 is not ABI compatible with Swift 4.0, so the binaries you use as dependencies need to be recompiled.

Two approaches are reasonable here:

  1. Use Carthage that will rebuild the Realm for you. (or build the Realm from source youself)
  2. If you are not using Carthage or you don't wish to building Realm from source yourself, just install external Swift 4.0 Toolchain and select it within Xcode -> Preferences -> Components -> Toolchains so you are back with Xcode 9.0 swift toolchain until Realm will release their update.

Upvotes: 3

milo
milo

Reputation: 976

I had the same issue, but with the module SocketIO. Recompiling the framework with Carthage worked for me. After that I also had to clean the build folder.

Upvotes: 1

Related Questions