Re-sync bundled seed file

Hi there RealmSwift experts!
Say I have a bundled realm used as a seed for my app with 10 objects in it in my app v1.
For my app v2, I added another 10 objects to the bundled seed file. What are best practices to get my app to sync these new objects?
And what are the pitfalls I need to be vigilant about?


My current approach is to have versioning for each update of the seed file (versions will be stored in user defaults and compared with the target version).

When a version update (which indicates that new data is added to the seed file) is triggered
1- Create new realm (with tmp fileUrl) based and use the updated seed file for it
2- From the new realm, copy (deep copy) of each added object and add it to the existing app realm
3- Update the current version to reflect that we did the migration to the new version
4- Clean up the tmp realm that was created in step one

Does this sound reasonable? any ideas?

It’s a bit of a vague question with probably 100 different approaches. We don’t know if this is a sync or local only Realm. We also don’t know what is meant by ‘sync’ in this use case. Does sync mean to copy the contents of the bundled Realm to the Realm stored locally?

It sounds like each version release will have a bundled realm, right? So that release would know if there are 10, 20, 30 objects with it’s release so if the current installed version has 10, and the new release has 20, copy the extra 10 objects into the Realm file.

You could also use a versioning approach as you mentioned or scan the existing realm file for differences and then add the new objects… there are a lot of options.

Hi Jay,
Thank you for helping out. It is a locally stored realm for an “offline” only app with no backend.
Basic idea the app has plenty for data to show to the user, the user interacts with these data, add notes, and the app stores the logs with relation to these objects locally.

One of the straightforward approaches was to write the diff of every release in code as instance, write them to the realm. But the whole purpose of the seed file (as far as I understood, relatively n00b here) is to avoid that.

Hence I wanted to find alternatives. Seems like you also agree with the approach I described in my first comment above