问题
I'm looking at using Realm for a project where we have both iOS and Android clients.
It looks like there's not any way to ensure that the database schemas are the same on both platforms, such that the data stores could be exchanged between them. Since the schema is effectively defined in code, how can I ensure they remain compatible?
回答1:
The Realm browser can generate Models from existing Realm files in multiple languages. So maybe you could create a realm file on one platform and then use the browser to generate the counterpart for the other language?
回答2:
The realm documentation says that Realm files are cross platform.
https://realm.io/docs/swift/latest/#finding-a-realm-file
You can follow the instructions in that section to make sure your schemas are the same.
来源:https://stackoverflow.com/questions/33091489/how-can-i-ensure-realm-schema-is-identical-across-android-and-ios