You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are currently using Realm Objective-C in our production app and considering migration options. Now our app mostly written on Swift, but we still use legacy Realm in Swift code too.
We found this discussion mentioning that Realm Swift and Realm Objective-C APIs are not interoperable
Questions
Mixed Usage
Is it technically possible to use both Realm Swift and Realm Objective-C in the same app?
What kind of issues might we encounter if we try to do this?
Are there any known crash cases or data corruption risks?
Migration Path
How complex would it be to migrate existing Realm Objective-C tables to Realm Swift?
Is there any migration tooling or recommended approach?
Would this migration be easier compared to migrating to a completely different database?
Documentation
We noticed that the warning about mixing APIs is not present in current documentation
Could you clarify the current official stance on this?
The text was updated successfully, but these errors were encountered:
Importing both the obj-c and Swift SDKs at once is perfectly fine and is in fact the intended way to use Realm in a mixed-language project now. RLMSupport.swift is now part of RealmSwift, along with some other helpers for using the obj-c API from Swift that couldn't be implemented in that way.
Interacting with Realm from Objective-C requires defining your models in objc, and using RLMObject subclasses requires using mostly the objc API. Mixing them doesn't work in that most things just won't compile due to there being different types involved, but there's otherwise no problems. As long as you don't work around problems with unsafeBitcast() or something there aren't really surprise problems where something will compile but not actually work.
Migrating to the Swift API will require touching nearly every line of code which touches Realm, but it should be exclusively very shallow changes. Everything is spelled slightly differently to align with Swift conventions, but there's no significant structural differences other than that the Swift API doesn't have the query functions which use the default Realm rather than take a Realm parameter.
Context
We are currently using Realm Objective-C in our production app and considering migration options. Now our app mostly written on Swift, but we still use legacy Realm in Swift code too.
We found this discussion mentioning that Realm Swift and Realm Objective-C APIs are not interoperable
Questions
Mixed Usage
Migration Path
Documentation
The text was updated successfully, but these errors were encountered: