Manngo
Manngo

Reputation: 16311

Where is CoreData located?

I am writing an app which uses CoreData using NSPersistentContainer to save data.

While I am developing the app, I would like to:

I assume the data is physically stored somewhere, but I’m not sure where to look.

Upvotes: 2

Views: 142

Answers (1)

gcharita
gcharita

Reputation: 8337

By default NSPersistentContainer stores the database inside app container under directory Libray/Application Support

enter image description here

To locate the full path, in simulator, you can print the applicationSupportDirectory using urls(for:in:) function of the default FileManager:

print(FileManager.default.urls(for: .applicationSupportDirectory, in: .userDomainMask).first?.path ?? "nil")

If you are running your app on an actual device you can download the application container following this answer.

For sandboxed apps the location goes like this:

~/Library/Containers/…/Data/Library/Application Support/…

Upvotes: 2

Related Questions