问题
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