Where is my sqlite data stored in iOS simulator?

10,201

Solution 1

let dirPaths = NSSearchPathForDirectoriesInDomains(.documentDirectory, .userDomainMask, true)

let docsDir = dirPaths[0]

print(docsDir)

Get the path printed in the debugger, copy it, open finder and press Cmd+Shift+G. A dialog box of Go to folder will open and paste the path and hit enter. You will be navigated to that folder. All the documents created in your project will be present in that folder including the .sqlite file. Don't try to navigate to that folder manually. Chances are you are looking at the wrong folder.

Also don't worry when every time Xcode prints a different path. Its a change brought from Xcode 6 onwards. Don't know why. But your files(those documents) will probably stay updated.

Solution 2

This is My app's folder:

/Users/***/Library/Developer/CoreSimulator/Devices/4420949E-AD14-4A4F-9153-53891734BEB9/data/Containers/Data/Application/0A18183F-2CF6-4D72-938D-DF59CFA48CCF

you can find your app's folder by the following code:

NSString *strPath = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];

Or just add a plugin: NCSimulatorPlugin

Solution 3

I have the same issue when using core data,

Some how i solve the problem with following steps:

  1. print the url of my sqlite file in console

  2. copy the url

  3. open a finder and press cmd + shift + G

  4. paste the url and press enter

Then the sql file will be showed.

I haven't use PhoneGap, but if you can print the sql file url from SDK ,

you can find the file as well.

Solution 4

Standalone app

As of Swift 4+, add a breakpoint somewhere to stop your code, then in the console:

po FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).last!

You can then find an sqlite file in one of the subdirectories. It can be different, depending on iOS versions.

If you are using an App Group (or alternate method for standalone app)

If data is shared among multiple apps, the method above will not work. But you can also follow this method if you just did not find the sqlite file.

You can get Xcode to print the path:

  1. Open Product > Scheme > Edit Scheme > Run > Arguments
  2. Add -com.apple.CoreData.SQLDebug 1 argument in "Arguments Passed on launch"

Next time you launch the app, you should see something like this in the log output:

CoreData: annotation: Connecting to sqlite database file at /Users/***/Library/Developer/CoreSimulator/Devices/****/data/Containers/****/YourAppName.sqlite

As a bonus, you'll also get a bunch of other Core Data debug info.

Share:
10,201
michelle9090
Author by

michelle9090

Updated on June 04, 2022

Comments

  • michelle9090
    michelle9090 almost 2 years

    I created an iPad app on xCode(using PhoneGap) with sqlite plugin, stored data, and then when I want to view the data I stored I couldn't find where I saved it. According to my online research, it should be under /Library/Developer/CoreSimulator/Device

    However when I navigate to the /CoreSimulator file, I don't see a sub-folder "/Device", just "/Profiles/Runtimes"?

    When I reopen the app and wanted to check my stored data I couldn't see them aswell.