Realm: Module was created by an older version of compiler and could not build objective-c module

4.6k Views Asked by At

enter image description here

I have followed the steps provided to add the framewowrk from this link https://realm.io/docs/swift/latest/

It gives this error what could be the issue?

Is it because it is compiled with an older version of xcode, since I have the latest xcode 7 beta?

If so, how would I solve this?

3

There are 3 best solutions below

0
On BEST ANSWER

You'll have to wait for us to support Swift 2.0 (#2062) before you can use Realm Swift in your Swift 2.0 project.

Because the framework written in Swift which was built in the old version compiler is not able to use in Xcode 7. Therefore, it will be needed to re-build using the compiler of Xcode 7. However, Swift 2 is required on Xcode 7; we are working to adapt RealmSwift.framework to the Swift 2.

1
On

I got Realm to work with Swift 2 by doing the following (this is from memory)

  1. Checkout Swift-2.0 branch https://github.com/realm/realm-cocoa/tree/swift-2.0
  2. Build by running /build.sh ios-swift
  3. Copy Realm.framework and RealmSwift.framework into project
  4. Use let realm = try! Realm() as my initializer in place of let realm = Realm()

I use Carthage for all my frameworks, so to keep things uniform I copied the RealmSwift and Realm frameworks into the carthage/build/ios directory and the /usr/local/bin/carthage copy-frameworks build script picks them up

0
On

This just randomly started happening to me as well for some reason. Manually compiling the swift-2.0 branch didn't end up working at all.

I ended up converting my entire project to Swift 2.1, and using the pre compiled frameworks. Now I'm up and running.

FWIW - The conversion to 2.1 from 2.0 wasn't nearly as painful as any of the other conversions from 1.0, or 1.2.