Add pre-filled realm database to iOS App


(Sal Aldana) #1

So I have a pre-filled real database with all the data my app will need but I’m having trouble trying to figure out where/how to add this realm file to my Xcode project and read from it. I thought it would be a simple drag/drop and then I could reference it using Bundle.main.path but I can’t seem to read any data from the realm file. Is there something missing/extra that needs to be done to use a pre-filled database?


(Ian Ward) #2

@saldana There is a build phase where you need to make sure the resource is imported and copied into the app. I would also recommend that you keep it in the default documents directory.


(Sal Aldana) #3

Thanks @ianward, after piecing together some information in a few different tutorials I was able to get the bundled realm copied on launch if needed to the documents folder and then opened it from there. So far I’m able to get data just fine now.


(Bernardo Henriques) #5

Hi, would you be so kind to list the exact steps that one needs to do?
I am using a realm and can do whatever i need with it on Xcode with the simulator but I cannot see anywhere and on realm docs a clear step by step list on what to do to bundle the realm with the app… such that I can start using my iphone to test my App with a preloaded realm database!
Thanks in advance!