Do we need migration for adding new "ignoredProperty"?


We have added new ignoredProperties, after updation client deleting all the data

var xxxx:CGFloat!

var yyyyy:DateInRegion!

var xxxxxxx:String!

var xxxxxxx:Array<scss> = Array();

override static func ignoredProperties() -> [String] {
return [“xxxx”, “yyyyy”, “xxxxxxx”, “xxxxxxx”]


In our experience, I don’t believe you need to explicitly define which vars to ignore at this point. If they are not set to @objc dynamic, they will not be managed by Realm anyway.

So if how you are defining your vars is shown in your question, they are ignored. Here’s an example:

class Person: Object {
    @objc dynamic var tmpID = 0 //would be managed but it is ignored per ignoredProperties
    @objc dynamic var firstName = "" //managed by Realm
    var carType = "" //not managed by Realm and is ignored

    override static func ignoredProperties() -> [String] {
        return ["tmpID"]

I am sure there are edge cases so please feel free to correct me.



If they are not set to @objc dynamic, they will not be managed by Realm anyway.

Are you sure about that?
I had an issue when i forgot to add the @objc to the properties. The data saved to the realm - i could see in the realm manager, but when i tried to get it, it was empty or default value.

For the question:
you should not write migration for the ignoredProperties, because it should not cause new schema version - but you can easily test it. Just modify one and see the migration callback on the next application start.


No. I am not sure! lol. However, Realm only manages Objc vars and defining it like this

var carType = ""

is a Swift var. You must include @objc dynamic to expose a var to the ObjC backing code. From Swift 4 forward I don’t believe there’s any way for Realm to work with an object that’s not defined as @objc so it would not be written to Realm.

Also, we have dozens of objects in our projects defined like that and none of them are showing up in Realm Studio.

There may be a case when a class is defined with @objcMembers however.

Again, just going from experience here so I may be off base. It works for us though.


Hmm, i will check this out later, it seems that we have different experiences - maybe this is not presented on the current realm/swift version :slight_smile: