15

I am creating an iphone app within XCODE the makes use of an SQLite3 database. I am creating the database programmatically if it does not exist. I am not getting any errors when I run the program.

How can I check the contents of the database to ensure that the data has been inserted correctly into the correct columns? Where does Xcode place the table within my system where I can view it?

mmmmmm
  • 32,227
  • 27
  • 88
  • 117
draion
  • 443
  • 2
  • 6
  • 11

5 Answers5

28

The SQLite database will be created in your apps Documents folder, in the simulator's base directory.

Before Xcode 6, you can check in:

~/Library/Application Support/iPhone Simulator/4.2/Applications/GUID/Documents

There is also a Mac OS X application called SQLiteBrowser that you can use to browse the database your app created.

Update :

As of Xcode 6, the new iOS simulator's directory is located here :

~/Library/Developer/CoreSimulator

Ultimately, you can find your app's database under a location like this (Replace UIDs by yours) : ~/Library/Developer/CoreSimulator/Devices/4D2D127A-7103-41B2-872B-2DB891B978A2/data/Containers/Data/Application/0323215C-2B91-47F7-BE81-EB24B4DA7339/Documents/MyApp.sqlite

Source: SO: Xcode 6 iPhone Simulator Application Support Location

Community
  • 1
  • 1
WrightsCS
  • 50,551
  • 22
  • 134
  • 186
  • 4
    The simulator directory has been moved with Xcode 6 to: `~/Library/Developer/CoreSimulator`. To find the unique path add the following statement to the `AppDelegate.m` file `applicationDocumentsDirectory` method: `NSLog(@"%@",[[[NSFileManager defaultManager] ` `URLsForDirectory:NSDocumentDirectory ` `inDomains:NSUserDomainMask] lastObject]);` – Brabbeldas Mar 19 '15 at 12:47
  • You're right @Brabbeldas, I added the new Xcode 6's simulator folder as an edit to the original answer so it is more pertinent. – Habovh Jun 10 '15 at 09:14
7

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

Open finder press 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

Vineesh TP
  • 7,755
  • 12
  • 66
  • 130
  • The simulator directory has been moved with Xcode 6 to: `~/Library/Developer/CoreSimulator`. To find the unique path add the following statement to the `AppDelegate.m` file `applicationDocumentsDirectory` method: `NSLog(@"%@",[[[NSFileManager defaultManager] ` `URLsForDirectory:NSDocumentDirectory ` `inDomains:NSUserDomainMask] lastObject]);` – Brabbeldas Mar 19 '15 at 12:49
1

The simulator directory has been moved with Xcode 6 to: ~/Library/Developer/CoreSimulator. To find the unique path add the following statement to the AppDelegate.m file, applicationDocumentsDirectory method:

NSLog(@"%@",[[[NSFileManager defaultManager] URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask] lastObject]);

Brabbeldas
  • 1,939
  • 4
  • 20
  • 32
1

Xcode 9.1:

  1. Open Terminal, type:

    cd ~ & find -name "YourModelName.sqlite"

  2. You'll most likely be presented with such a path:

~/Library/Developer/CoreSimulator/Devices/XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/data/Containers/Data/Application/YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY/Library/Application Support/

  1. Open Finder, press Shift + Command + G, paste the path and press Go.
  2. Use DB Browser for SQLite to view the .sqlite file.
Omid Ariyan
  • 1,164
  • 13
  • 19
0

There are a bunch of standalone programs that look at sqllite files. A very popular one for the Mac is called "Base":

http://itunes.apple.com/us/app/base/id402383384?mt=12

Kendall Helmstetter Gelner
  • 74,769
  • 26
  • 128
  • 150