Is it possible to release an iOS App with data already in Realm database


#1

Hi,

I have an app that currently uses Realm database locally, everything works fine but now I need to add a second table to the existing database (default.realm) the issues is that this new table will contain pre-existing data (about 50k records), in other words, I would like to include this data already in my app/Realm.

Is it possible to release an iOS app with objects already in Realm? In other words, enter the records locally via export using the Realm Browser.

Is this possible or the data must reside in a server or in a separate file locally?

The reason I want to have the data included in the device is because this data will be the same for all users and will never changed.

FYI - I have been able to import the data using the Realm Browser and I’m able to read the data using the simulator in XCode.

Thanks a lot,
I love Realm!


#2

Hello,

Realms are just files, so if you already have a filled up realm you can embed it in your IPA (or make it downloadable through a server) and on first launch, copy it to your documents folder in order to open it with Realm. Here is the doc for opening a local realm : https://realm.io/docs/swift/latest/#opening-realms

Another solution would be to add an xml or csv file with your data, and on first launch, open this file and insert all the data in your default realm database.