How to Find Realm File Location of a MAC App

How to find Realm file location of a Mac App

The Realm does change when you create new file.

Just add the following line to your ViewDidLoad method:

print(Realm.Configuration.defaultConfiguration.fileURL!)

This line will print the location to XCode console. Copy the file path, go to Finder -> Go -> Go go Folder... -> paste the path and hit Go.

How to find my realm file?

Finding a Realm File

For Android

How to view my Realm file in the Realm Browser?

For iOS

If your App is on Device

Make sure that your device is connected and go to the devices window in the Xcode menu Window > Devices (⌘⇧2). There you will be able to choose your device and your app from a list of installed apps with debugging permissions.

After selecting your app, go to the cog in the toolbar at the bottom of the table view and select “Download Container…“. There you will be able to pull the file from the documents location to your Mac. It will be saved as an xcappdata bundle.

When you open the local path in Finder, where you saved it, you can tap into that by selecting “Show Package Contents” in the context menu of the finder, when you select the file. A new finder window will open, where you find your Realm inside in the following path (e.g.): AppData/Documents/default.realm (The directory '/private/var/mobile' is the path, which is used by iOS on the device filesystem.

If your App is on the Simulator

Go to your user’s directory:

/Users/<username>/Library/Developer/CoreSimulator/Devices/<simulator-uuid>/data/Containers/Data/Application/<application-uuid>/Documents/default.realm

Probably the easiest way to get the current path of the default realm is to pause the simulator and enter the following into the LLDB console:

Objective-C:

(lldb) po [RLMRealmConfiguration defaultConfiguration].fileURL

Swift using Realm Objective-C:

(lldb) po RLMRealmConfiguration.defaultConfiguration().fileURL

Swift using Realm Swift:

(lldb) po Realm.Configuration.defaultConfiguration.fileURL

Or if you have an RLMRealm instance at hand, you can use:

(lldb) po myRealm.configuration.fileURL

Then just copy this path, open your terminal, and type open [Pasted path here]

NOTE: Some paths have a space in them so be sure to use "\" before the space to escape it

Helper Tool SimPholders

This is probably the fastest way to find the file of an app in the simulator. Install SimPholders. This will allow you to access your app’s documents directory directly from your menu bar.

Note Some people have mentioned that SimPholders has taken them to the wrong simulator app folder, if that's the case for you, print out your realm path by following the steps above, printing out your realm.path

Why can't I find the directory on my computer for the default.realm file for the connection to Realm Studio?

well, I finally figured it out. I ran my app on my iPhone because I can't use the simulator since I need the camera. This is why it gave me the var/mobile directory. I found this detailed explanation about what to do when the app runs on the device rather than the simulator: How to find my realm file?.

How do I open an iOS simulator local .realm file in Realm Studio

The fact that Realm Studio does not yet open files in response to the open AppleEvent (sent by double-clicking on a Realm file in the finder, or using open on a .realm file) is a known issue.

In the mean time, you can open it via Realm Studio's Open panel by first copying the path, typing / when the Open panel is showing, then pasting the copied path into the text field that has appeared.

Find path for Realm file with Realm React Native to use with Realm Browser

Just found the answer myself by digging through the docs:

console.log('create db:', db.path)


Related Topics



Leave a reply



Submit