Incompatibility with new Swift compiler?

I’m fairly new at using Realm with Swift and with RealmSwift in general, so I may have missed something here.

I have a SwiftUI music project that I’m developing and it was working fine with RealmSwift until yesterday. Now I get messages about the compiler being incompatible. So to try to find out more, I tried to create a new SwiftUI project using RealmSwift in realm-cocoa and found that I could not get it to load, hanging on “Verifying realm-cocoa”.

Here’s the compiler-related error I am getting with my main project:

/Users/brucecichowlas/blue/sami/210723/SAMI/SAMI/Views and ViewModels/Selection Views/NamedPatchSelectionView.swift:9:8: error: module compiled with Swift 5.5.1 cannot be imported by the Swift 5.5.2 compiler: /Users/brucecichowlas/Library/Developer/Xcode/DerivedData/SAMI-bwvakqpaaigygsbyohqxxlboahbx/Build/Products/Debug-iphonesimulator/RealmSwift.swiftmodule/x86_64-apple-ios-simulator.swiftmodule

import RealmSwift

I tried building from source and did manage to get a successful build with Frameworks, which I tried to drag into the project, but got errors with that, probably due to inexperience trying to incorporate Realm that way. module ‘RealmSwift’ was created for incompatible target x86_64-apple-macos10.9: /Users/brucecichowlas/blue/try/210805/TryRealmOnIOS/TryRealmOnIOS/RealmSwift.framework/Modules/RealmSwift.swiftmodule/x86_64.swiftmodule I’d much rather go back to using RealmSwift in realm-cocoa as before, but I suppose I could build from source if I could figure out errors like this one.

But the problem I am most interesed in solving is the first one with the apparent compiler version mismatch.

Suggestions?

Thanks,
Bruce

Hi @Bruce_Cichowlas,

I guess this comes from the new Xcode 13.2, as Xcode 13.1 has Swift 5.5.1 instead, can you please confirm?

The most compatible way to embed Realm in an Xcode project is via Swift Package Manager (that however has an issue - solved by installing the non-App Store version of Xcode or going back to 13.1), are you using that, pre-built binaries (that may well give that type of errors) or another package manager?

I’ve been using RealmSwift from the realm-cocoa Swift Package.

GitHub - realm/realm-swift: Realm is a mobile database: a replacement for Core Data & SQLite master branch

That’s also the one that hangs at the verify stage when I try to make a new package with it.

I am on Xcode 13.2. I think that is why it is using Swift 5.5.2 instead of Swift 5.5.1. I looked for something fine-grained enough in the Xcode target settings to let me specify that version of Swift, but the only thing I found was Swift 5 vs Swift 4. Perhaps there is a way to specify it in there somewhere, but I didn’t see how when I looked.

I’m in the process of downloading the 9GB Xcode 13.1 and perhaps I will be able to use that in the meantime.

I really appreciate your quick attention. I do free music performance apps on the side with my liimited time and I am trying to get some new things out. Thanks!

Hi @Bruce_Cichowlas,

My impression is that it has more to do with the SPM bug that 13.2 has, rather than the Swift compiler itself.

That certainly works for SPM packages, I’m using that myself. You may want to Clean the target upfront, to ensure the packages are built from scratch.

That’s great! Please keep the Community updated with your efforts, it’s always nice to find out how Realm is used out there.

Just wondering whether anything has changed on this issue. I’d like to use Xcode 13.2.1 instead of Xcode 13.1, but this issue makes me have to use Xcode 13.1.

We are and have been running XCode 13.2.1 with Realm since release with no issues what-so-ever.

But…

We gave up on SPM months ago and all Realm projects are instantiated using Cocoapods - we create different test projects daily and it really is smooth sailing.

Thank god I found this forum.

I’ve installed xCode 13.3 Beta because it’s the only xCode that will run apps onto my iPhone (iOS 15.4 Beta 2). I’ve been running into
error: Segmentation fault: 11 (in target 'RealmSwift' from project 'Realm') and error: Abort trap: 6 (in target 'RealmSwift' from project 'Realm')
My understanding from this conversation is that I need to redownload the old version of xCode, specifically 13.1/ 13.0, and then I can be able to use Swift Package Manager to install RealmSwift?

If you need to do development in a beta environment, then yes that solution mostly works.

However, you’ve got a number of uncontrollable variables there; iOS Beta, XCode 13.3 Beta and SPM which is already known to have issues with 13.3 and 13.2. Then throw in Swift 5.5.1 to 5.5.2 and well, your mileage may vary.

I would advise sticking with releases instead of beta’s for the time being if possible. It will reduce the configuration issues and enable you to focus on the coding instead of juggling the development environment.

Just my .02

1 Like

This worked, I downloaded xCode 13.0, everything works like a charm :slight_smile: