Can't Find iPhone Simulator's SQLite Database : Using Magical Record

蹲街弑〆低调 提交于 2019-12-06 16:17:49

问题


In my application's documents folder, I do not find my SQLite database

Library/Application Support/iPhone Simulator/6.1/"random app id"/Documents/

^This folder is empty

MagicalRecord seems to be working, I just have no idea how to find the database.

I use the following to set up Magical Record

[MagicalRecord setupAutoMigratingCoreDataStack];

So where does MagicalRecord store its database?


回答1:


MagicalRecord stores, by default, all data stores in the following location:

{App Folder}/Library/Application Support/{App Name from Info.plist}/{storeName.sqlite}

This is easily accessible from the simulator as well as documents.




回答2:


You can log your SQlite file location using the following NSPersistentStore MR addition :

[NSPersistentStore MR_urlForStoreName:[MagicalRecord defaultStoreName]]



回答3:


If you know the name of the sqlite file then just do a search in OSX for that file to find the directory. Otherwise the file was never created.

Make sure you are setting up the CoreData stack correctly as per the documents.

+ (void) setupCoreDataStackWithAutoMigratingSqliteStoreNamed:(NSString *)storeName;



回答4:


Swift + Xcode 7 + simulator 9.0

Please go to your AppDelegate.swift

change

MagicalRecord.setupCoreDataStackWithStoreNamed("yourDBName.sqlite")

to

MagicalRecord.setupCoreDataStackWithAutoMigratingSqliteStoreNamed("yourDBName.sqlite")

Now you can locate the yourDBName.sqlite at /Users/userName/Library/Developer/CoreSimulator/Devices/"random app id"/data/Containers/Data/Application/"random app id"/Library/Application Support/ProjectName

There is a useful tool: simPHolders2 (http://simpholders.com) simPHolders easy to access all application folders



来源:https://stackoverflow.com/questions/16426536/cant-find-iphone-simulators-sqlite-database-using-magical-record

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!