3

I've seen other questions asking the same thing and they're all marked as "answered" but the answers they provide are not working for me.

I created a base cocoa application in Xcode 5 and made it a Core Data/Document app. I added a few entries to Core Data and can see them in NSLog when I read them back... now where is my sqlite DB located?

I checked: ~/Library/Containers/

And my app is not there.

I checked: ~/Library/Developer/XCode/DerivedData/

And I found my app there, but I went through every single folder and can't find the SQLite at all.

Can anyone tell me where this is at? This is a Mac OSX app, not an iOS app.

3
  • are you sure you are using sqlite as your storage? it should be at ~/Library/Application Support/appname/ IIRC, but im sure you can change the path to whatever you like. just search your library folder for it. Commented Nov 29, 2013 at 17:53
  • How did you make it a Core Data/Document app ? How do you setup the Core Data stack? Are you using NSPersistentDocument ? Commented Nov 29, 2013 at 20:08
  • 2
    I just created a test app using Xcode 5/Mavericks and checked the "Document based app" and "Core Data" options and it seems to work the same way it does in earlier versions. You have to use File->Save to save the document to disk and then enter the filename and select the format (binary, sqlite, xml). Commented Nov 29, 2013 at 20:15

1 Answer 1

9

The data store file is... Wherever you put it. The location is not automatically generated, it's wherever your code says it should be. Specifically, when you call addPersistentStore:, you pass in a file URL that determines the location. Find that call and see what path it's using.

Commonly, but not always, this is in the Application Support folder. If your app is sandboxed then that's somewhere in ~/Library/Containers/. If your app is not sandboxed then it's somewhere in ~/Library/Application Support/.

But the store doesn't have to be in Application Support. It can be anywhere that your app has file write privileges. If your app isn't sandboxed, it could go anywhere that the current user has file write privileges. It's wherever you tell Core Data to put it.

Sign up to request clarification or add additional context in comments.

1 Comment

This was it. I was using a helper function to create the persistentStore that was automatically dumping it in my documents directory. Thanks for pointing that out!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.