Search code examples
iosobjective-cswiftrealm

Realm crash on iOS 10 with 'String'


I have recently released a new version of our app and during beta testing, it's crashing on all iOS 10 devices but not other versions. Since we have Crashlytics, we found a strange crash message in the backend that we can confirm is the reason all iOS 10 crashing since it's 100% iOS 10 and there's like 40 of them.

It reads as follows:

Fatal Exception: RLMException Property Article.id is declared as String, 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 https://realm.io/docs/swift/latest/api/Classes/Object.html for more information.

And here's the object:

class Article: Object {
    
    @objc dynamic var id: String = UUID().uuidString
    // others...

    override static func primaryKey() -> String? {
        return "id"
    }
}

As you can see, this is perfectly nomral and runs fine on other iOS. In Realm's doc, it LITERALLY SAYS to use String with @objc dynamic and there's no way it's unsupported. I suspect there's nothing special about Article.id, and since Article starts with A, it happens to be the first String property of all realm Objects. Maybe somehow all Strings stopped working on iOS 10?

Can anyone offer some advice or insights?(Please don't say things like drop iOS 10 support. For now, we need it.)


Solution

  • Turns out it was a Realm's bug. We happen to have another app that runs just fine on iOS 10, and after some inspection we realized that it was using Realm 4.3.2, instead of 4.4.1. After we downgraded Realm to 4.3.2, this problem disappeared.