16

I'm having a hard time trying to understand a problem in my iphone app.

I have a set method in my sqlite database that looks like it is working fine. I do a NSLog when I am setting the value and it is correct. It's a string with the value "2010-10-10 12:13:14".

When I use the get method on the same data, it turns out that the value is not correct. It returns 1.

Is there any way to open the database file that is inside the iPhone simulator so I can see what is the actual data stored in the simulator database?

Is there any way to sniff the sqlite calls between my simulator and the actual file? Something like Charles, or Service Capture?

Many thanks!

Mauro
  • 163
  • 1
  • 1
  • 4
  • 1
    Possible duplicate of [How to view the data in sqlite file running in iphone application?](http://stackoverflow.com/questions/4644158/how-to-view-the-data-in-sqlite-file-running-in-iphone-application) – Sandy Chapman Nov 20 '15 at 16:48

8 Answers8

28

Since IOS 8 they put it in a different folder:

Library/Developer/CoreSimulator/Devices/(numbers and letters)/data/Containers/Data/Application/(numbers and letters)/Documents/

Check this answer for more info

Community
  • 1
  • 1
bicycle
  • 8,315
  • 9
  • 52
  • 72
24

If you want to view the database that you have created,

Open finder -> press SHIFT + Command + G -> "~/Library/Application Support/iPhone Simulator" then go.

Open 5.0 (as per your version of simulator)-> Application-> select the pgm folder

-> Documents

enter image description here

Then you can see the database

enter image description here

Abdurrahman Mubeen Ali
  • 1,331
  • 1
  • 13
  • 19
Vineesh TP
  • 7,755
  • 12
  • 66
  • 130
10

Update: I made a tool to automate this

Both for Android and iOS, it's available here


Old question, but Apple seem to keep change the logic...

On macOs Sierra you can find the database location by issuing the following commands (the simulator must run during the process!)

ps aux | grep 'CoreSimulator/Devices'

The result should list the path to the simulator, for example:

/Users/user1/Library/Developer/CoreSimulator/Devices/25C1F5DA-E528-4BC2-B684-A92D382553AC/data/var/run/launchd_bootstrap.plist

Navigate to the now found simulator folder:

cd /Users/user1/Library/Developer/CoreSimulator/Devices/25C1F5DA-E528-4BC2-B684-A92D382553AC/Data/Application/

This folder contains all the simulator applications

From here if you know the database name, just find it, like so:

find ./ -type f -name 'my_db.db’

And viola! You have the database path :)

Community
  • 1
  • 1
Nadav96
  • 1,274
  • 1
  • 17
  • 30
  • With Version 11.0 (SimulatorApp-912.1 SimulatorKit-570.3 CoreSimulator-681.5.1) of the CoreSimulator, our friends at Apple got even more clever. ps -aux |grep 'CoreSimulator/Devices'. returns something that is not a real path to the application. /.../CoreSimulator/Devices/E02979D7-17B7-43A7-B66B-AC3921CD6B85/data/Containers/Bundle/Application/1BB978A7-6922-479D-9D03-262AD614B980/MY_APP.app/MY_APP To use the find command, it is necessary to strip everything past Containers segment. – Charles Thomas Oct 02 '19 at 23:04
7

You can refer to the following link below,You can definitely look at the database stored inside the simulator.

How to view the data in sqlite file running in iphone application?

Cheers

Community
  • 1
  • 1
Aditya
  • 4,414
  • 5
  • 29
  • 40
5

For the 6.1 simulator, the location is different.

Start at:

~/Library/Application Support/iPhone Simulator/6.1/Applications/

Open the folder that represents the application on your simulator. The name will look similar this:

0951F670-1DAC-9A39-450A-B8EEFFC0FFE1

If you have multiple folders, then you can click into each folder and look at the app icon until you find the app that you are looking for. Alternatively, uninstall all other apps from the simulator except the one you are interested in.

From inside this folder, go here:

Library/Application Support/<APP_NAME>/<APP_NAME>.sqlite

The total path should look like this:

~/Library/Application Support/iPhone Simulator/6.1/Applications/<APP_ID>/Library/Application Support/<APP_NAME>/<APP_NAME>.sqlite
Nick Snyder
  • 2,966
  • 1
  • 21
  • 23
3
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];

NSLog(@"path is %@",documentsDirectory);

The above code will print the path of ur database and copy it. Go to finder and choose go to folder from menu (Shift+Win+G) and paste the path here, it will give you the exact path of core data file. Keep this window open.

Next step Go to Mozilla firefox click on menubar choose Tools -> SQLite Manager. It will open new window. In new window click on open file and drag that path of coredata file in current window and click on open.

Note - You must have Installed SQLite Manager in your Mozilla firefox.

Roman Marusyk
  • 23,328
  • 24
  • 73
  • 116
Gurjinder Singh
  • 9,221
  • 1
  • 66
  • 58
0

For 2019 and 2020 answer: ⚠️

This is easy. Use a free-opensourced application called Simsim (https://github.com/dsmelov/simsim).

Read the README and there's a direct download link there.

enter image description here


Choose Finder, and from there, you can find the .sqlite db file in the Documents or use the search function of the Finder targeting your application folder.

Glenn Posadas
  • 12,555
  • 6
  • 54
  • 95
0

Xcode 12.5+

  1. Find the path to .sqlite
let fileManager = FileManager.default
let databasePath = try fileManager.url(
                for: .applicationSupportDirectory,
                in: .userDomainMask,
                appropriateFor: nil,
                create: true
            )
            .appendingPathComponent("yourDatabaseName.sqlite")
            .path
  1. go to the file

Open finder -> press SHIFT + Command + G -> past the "file path" then go.

  1. view sqlite file and query it

https://inloop.github.io/sqlite-viewer/

YodagamaHeshan
  • 4,996
  • 2
  • 26
  • 36