I'm using Realm Swift SDK on my SwiftUI project. It all started when I updated the Realm package in the XCode Package Manager.
I faced some issues with the new version of Realm's Swift SDK and based on the docs - I removed Realm library, kept RealmSwift library, and changed the embed settings to Embed & Sign: here's the Target's General
Now - when I run the app - the realm isn't populated with data. I wish I could just roll back, but it's impossible - I get runtime error when I change RealmSwift to "do not embed":
dyld[13970]: Library not loaded: @rpath/RealmSwift.framework/RealmSwift
Referenced from: <0C0C4659-D88F-3302-B78E-AEF6E29D9636> /private/var/containers/Bundle/Application/C8216C2A-9D4F-4767-BEE4-70F977B5B509/MindCheckAI.app/MindCheckAI
Reason: tried: '/Users/itamargil/Library/Developer/Xcode/DerivedData/MindCheckAI-fmefsxngttqathgdnicimkgijggk/Build/Products/Debug-iphoneos/PackageFrameworks/RealmSwift.framework/RealmSwift' (no such file), '/private/preboot/Cryptexes/OS/Users/itamargil/Library/Developer/Xcode/DerivedData/MindCheckAI-fmefsxngttqathgdnicimkgijggk/Build/Products/Debug-iphoneos/PackageFrameworks/RealmSwift.framework/RealmSwift' (no such file), '/private/var/containers/Bundle/Application/C8216C2A-9D4F-4767-BEE4-70F977B5B509/MindCheckAI.app/Frameworks/RealmSwift.framework/RealmSwift' (no such file), '/Users/itamargil/Library/Developer/Xcode/DerivedData/MindCheckAI-fmefsxngttqathgdnicimkgijggk/Build/Products/Debug-iphoneos/PackageFrameworks/RealmSwift.framework/RealmSwift' (no such file), '/private/preboot/Cryptexes/OS/Users/itamargil/Library/Developer/Xcode/DerivedData/MindCheckAI-fmefsxngttqathgdnicimkgijggk/Build/Products/Debug-iphoneos/PackageFrameworks/RealmSwift.framework/RealmSwift' (no such file), '/private/var/containers/Bundle/Application/C8216C2A-9D4F-4767-BEE4-70F977B5B509/MindCheckAI.app/Frameworks/RealmSwift.framework/RealmSwift' (no such file)
- I made sure that the user exists, and that the user ID is found when the realm is bootstrapped.
- I checked logs - now there are no permissions to read/write (whereas before the change there were). Before:
Logs:
[
"Roles selected for sync:",
" readAndWriteAll: [ Analysis, Answers, Explainer, Form, NotificationPreferences, User ]"
]
Function Call Location:
DE-FF
Query:
{
"Explainer": "(TRUEPREDICATE)",
"Form": "((isPublic == true or creatorID == \"654a172a09bd5f2f6c1d49f0\"))",
"NotificationPreferences": "(receiver_id == oid(654a172a09bd5f2f6c1d49f0))",
"User": "(_id == oid(654a172a09bd5f2f6c1d49f0))",
"Analysis": "(respondent_id == oid(654a172a09bd5f2f6c1d49f0))",
"Answers": "(respondent_id == oid(654a172a09bd5f2f6c1d49f0))"
}
Remote IP Address:
189.62.45.236
SDK:
Realm Swift v10.42.4
Platform:
iOS vVersion 17.3.1 (Build 21D61)
After:
Function Call Location:
DE-FF
Query:
{}
Remote IP Address:
189.62.45.236
SDK:
Realm Swift v10.50.0
Platform:
iOS vVersion 17.4.1 (Build 21E236)
1 Answer 1
So I actually figured out the issue; it was the SDK versioning.
By removing Realm package and adding again with default version settings things went back to normal.
This issue was a bummer. My conclusion is (for Realm Swift SDK):
- Only use RealmSwift package, not Realm.
- Don't mess with the package settings; just add it with the default ones.
pod deintegrateand then re-add Realm. It also seems you may not be authenticated (correctly). Can you log out the user and log them back in?