macoscocoacore-datamacos-sierra

Where is my database located of my MacOS app?


What is the database location of a MacOS application when using Core Data ?

I searched everywhere on my Mac and did't find it.
I Have the hidden files OFF and I'm sure there is data in my database. Also I don't use app Sandbox.


Solution

  • Look for the persistentStoreCoordinator method in your AppDelegate.m. There is a line

    NSURL *applicationDocumentsDirectory = [self applicationDocumentsDirectory];
    

    Just add

    NSLog(@"myDirectory: %@", applicationDocumentsDirectory);
    

    This assumes you started your project with Xcode 8 Cocoa template with "use Core Data" option.

    Or add

    NSLog(@"Array of CD stores: %@", self.persistentStoreCoordinator.persistentStores);
    

    to applicationDidFinishLaunching, for example. The resulting path should be in your user's library Users/<user>/Library/Application Support/<whatever>/<appname>.storedata.