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

纵饮孤独 提交于 2019-12-04 19:10:25

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.

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

[NSPersistentStore MR_urlForStoreName:[MagicalRecord defaultStoreName]]

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;

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

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