0

I want to access the Realm data file which is created on iOS Simulator. With the instruction of this question, I got to the following directory:

~/Library/Developer/CoreSimulator/Devices/0AB2D954-A3D5-4ABF-A5C5-CC470FB4ABDE/data/Containers/Data/Application/7192723E-7582-48EB-8B66-14E1073D7CE6/Documents

However, the directory has only the following Realm files:

default.realm.note
default.realm.log_a
default.realm.log_b
default.realm.log
default.realm.lock

and I cannot find the Realm file default.realm.

Also, when I open up the Realm Browser and access to the directory, all the files above except default.realm.note is grayed-out and I cannot access the Realm data.

Note that I create a Realm instance and save data by realm.write:

try! self.realm.write {
    for (_, value) in json { // json is from SwiftyJSON
        let pitcher = Player()
        player.year.value = value["year"].int
        player.name = value["name"].stringValue

        self.realm.add(player)
    }
}

So how can I access the Realm data file?

Community
  • 1
  • 1
Blaszard
  • 30,954
  • 51
  • 153
  • 233
  • You can use this app https://github.com/somegeekintn/SimDirs – LE SANG Nov 22 '15 at 10:12
  • @blaszard Could you please make sure what does `print(self.realm.path)` show? And can you show the code around instantiating `self.realm` instance? – kishikawa katsumi Nov 23 '15 at 02:30
  • @kishikawakatsumi Forgive me that I'm late to reply, but I found `print(self.realm.path)` returns different paths between launches. As to your second question, I instantiated `let realm = try! Realm()`, which is the way it is instantiated in sample projects. – Blaszard Nov 27 '15 at 15:42
  • @kishikawakatsumi I should have clarified; the path is different in XXX of `~/Library/Developer/CoreSimulator/Devices/0AB2D954-A3D5-4ABF-A5C5-CC470FB4ABDE/data/Containers/Data/Application/XXX/Documents`, and the contents under `Documents/` still lack `default.realm`. – Blaszard Nov 27 '15 at 15:47

1 Answers1

0

Realm's auxiliary files (.note, .lock, etc) are always created next to the .realm file itself. So it seems like something is deleting the realm file without deleting the auxiliary files, which would explain why you can't find it.

Please make sure you're not deleting this Realm file somewhere in your code.

jpsim
  • 14,329
  • 6
  • 51
  • 68