Open sqlite database file inside iphone simulator?
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 corr开发者_如何转开发ect. 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!
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
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
Then you can see the database
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 :)
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
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
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.
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.
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.
Xcode 12.5+
- 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
- go to the file
Open finder -> press SHIFT + Command + G -> past the "file path" then go.
- view sqlite file and query it
https://inloop.github.io/sqlite-viewer/
精彩评论