Search code examples
swiftrealm

Object Classes not working with RLMSupport in Swift


Hello When using Realm and RLMSupport for Obj-C/Swift.

The app crashes with my conf when adding config.objectClasses

let appGroupIdentifier = "group.APContacts"
let dbFilename = "dbSwiftContacts.realm"

let config = RLMRealmConfiguration()
config.fileURL = FileManager.default.containerURL(forSecurityApplicationGroupIdentifier: appGroupIdentifier)!.appendingPathComponent(dbFilename)
config.objectClasses = [Dog.className()]
config.readOnly = true
RLMRealmConfiguration.setDefault(config)

The error is: This one!

Can anyone managed to get this working with RLMSupport?


Solution

  • I found the problem and solved it.

    Here is the correct field fixed: (using YourClass.self)

    config.objectClasses = [YourClass.self]
    

    Once there are no Doc for RLMSupport.swift , hope this will help someone.