IPhone core data simulator

2019-02-12 14:34发布

I've created an app that uses core data. Is there a way to view the sqlite db on the simulator? A tool perhaps that allows to query the sqlite db on the simulator? Like a data browser?

Is there a way to browse the iphone simulator to the sqlite db location?

6条回答
何必那么认真
2楼-- · 2019-02-12 14:48

Xcode 5

I just downloaded a trial of Base and was able to point it at the .sql database from the simulator via:

/Macintosh HD/Users/"username"/Library/Application Support/iPhone Simulator/"current iOS development version"/Applications/

The folder names for the applications are unreadable, but if you click on the folder you should be able to see the contents with familiar names.

Xcode 6+

This was changed in Xcode 6, and now is located at ~/Library/Developer/CoreSimulator/Devices/<device-id>/data/Containers/Data/Appl‌​action where the database itself can be found within the documents directory <app-id>/Documents/<name>.sqlite

查看更多
女痞
3楼-- · 2019-02-12 14:51

With Xcode 6, the simulator base directory can be found here:

~/Library/Developer/CoreSimulator/Devices/<device-id>/data/Containers/Data/Application

Then, the database itself can be found in the documents directory:

<app-id>/Documents/<name>.sqlite

The database can be accessed using sqlite3 on the command line.

查看更多
Viruses.
4楼-- · 2019-02-12 14:52

Try Lita, free and quite good.

查看更多
做个烂人
5楼-- · 2019-02-12 14:53

If you have the free sqlite3 installed, you can do so at the command line by doing:

/Users/<user>/Library/Application\ Support/iPhone\ Simulator/<sim_version>/Applications/<apphash>/Documents/<yourfile>

Easiest way to see which hash you should peek in:

ls -lt /Users/<user>/Library/Application\ Support/iPhone\ Simulator/<sim_version>/Applications/

You can run .tables at the prompt to see what tables are there, and .schema <tablename> to check out its columns.

查看更多
\"骚年 ilove
6楼-- · 2019-02-12 14:54

i´m quite happy with SQLite Manger for Firefox. Free AddOn.

查看更多
Summer. ? 凉城
7楼-- · 2019-02-12 14:55

This is a quite an old post, however I was looking for something else and I landed here, my 2 cents:

In reply to WINSergey: (1) The easiest way to recover your device ID and the entire path is to print:

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

Then you'll see the output on the Debugging area or opening the System Log from the simulator.

(2) Also, to know the Device ID from the simulator: XCode > WIndow > Devices > > it shows the Identifier on the right hand side.

I'm also using SQLiteStudio, it is Open Source and works well.

查看更多
登录 后发表回答