realm-swift icon indicating copy to clipboard operation
realm-swift copied to clipboard

Future RealmObjC vs RealmSwift compatibility

Open adomanico opened this issue 8 years ago • 7 comments

Wanted to pose a question regarding any planned compatibility between between the RealmObjc and RealmSwift frameworks.

Currently, all of our core models are written in objective-c and are all based off of the RealmObjc RLMObject base class. We would like to convert these models into Swift and base them off of RealmSwift's Object base class. The rest of our code in our project is Swift. Essentially all that is left in objective-c land for us are these RLMObject models.

It is my understanding that Realm & RealmSwift (RLMObject & Object) are not to be mixed and are not compatible. Unfortunately, the process of migrating all of our model objects in one fell swoop is simply too risky and not practical for the scale of our app.

It would be very useful if some compatibility was supported between the two frameworks so we could incrementally migrate our model objects over to Swift & the new RealmSwift Object base class. We will pretty much be stuck with these objective-c models and RealmObjc until an incremental solution is available.

Are there any plans for incremental migration support for moving to RealmSwift?

Thanks!

adomanico avatar Jan 24 '17 22:01 adomanico

Thanks for getting in touch with us!

We support using the Objective-C version of our binding in a Swift app, and we fully support using both Objective-C and Swift versions of the binding together, as long as they are kept separate and don't try working with each others' models and classes.

However, in 2.1.1, we did add new APIs to transfer objects between the Objective-C and Swift bindings in a principled manner. Take a look at our release notes (first bullet point under Enhancements) for more information.

Hope that helps.

austinzheng avatar Jan 24 '17 22:01 austinzheng

Thanks for the quick response,

I guess my core question would be: is it possible for an a RLMObject model to have a property / RLMArray of a Object base class?

If not, is this something that you are thinking of supporting?

This would allow us to slowly migrate our models from the bottom up.

adomanico avatar Jan 24 '17 22:01 adomanico

Hi Adrian,

Unfortunately we don't support having Objective-C and Swift model types inheriting from each other's base classes, and it's unlikely we'll add support for this in the near future. I can bring it up with our engineers.

austinzheng avatar Jan 24 '17 23:01 austinzheng

Thanks, would love to start a conversation internally about it.

I'm sure there are many other companies with scale that simply can't afford to migrate all of their core models in one swoop.

adomanico avatar Jan 24 '17 23:01 adomanico

Just following up:

Was there any internal discussion about this?

adomanico avatar Feb 24 '17 21:02 adomanico

Thanks for checking in. Unfortunately we have other issues that take priority over this one and limited engineering bandwidth, so the best I can do for now is to put it in our backlog.

austinzheng avatar Feb 24 '17 21:02 austinzheng

Is it possible to transfer RLMObject (Objective-C) properties into Object(Swift)?

Goal

  • We have a data model subclass of RLMObject with many proprites and we are stroing every thing in relam but not using all those properites.

  • We are plning to enhance out local database structure with new Swift based relam model to utilizing memory more efficiently.

Expected Results

  • From all existing data model object we want to tranfer some propreties into new model(table) using some realm migration.

@bmunkholm @jpsim @austinzheng Can you guys help me on this?

Thanks!!!

BaluNaik avatar Feb 05 '19 12:02 BaluNaik