I have a project with Swift 3, and I update to Swift 5, I deal with a lot of problems.
Now I have a problem like topic, I have problem to use singleton with Realm Struct.
After updated to Swift 5, I also updated RealmSwift to 5.5.1(original is 3.X.X) to solved “Primary key property ‘id’ does not exist on object”.
However, when I want to call the Struct RealmHelper, it will get error with this:
“Property FilterModel.type is declared as FilterType, which is not a supported managed Object property type. If it is not supposed to be a managed property, either add it to ignoredProperties()
or do not declare it as @objc dynamic
. See Object Class Reference for more information.”
I don’t have any way to solve it.Now I use Xcode 13 with Swift 5.
This is my code:
`import RealmSwift`
struct RealmHelper {
static let sharedInstanse = RealmHelper()
fileprivate let version: UInt64 = 0
fileprivate var config: Realm.Configuration
let realm: Realm
```
private init() {
do {
config = Realm.Configuration(
schemaVersion: version,
migrationBlock: migration()
)
Realm.Configuration.defaultConfiguration = config
realm = try Realm(configuration: config)
} catch let error {
fatalError("Realm Error Can't Open : \(error)")
}
log.info("Realm Path: \(config.fileURL!.absoluteString)", userInfo: Tag.sensitive.dictionary)
}
func …
}
Thank you!