Standalone app
As of Swift 4+, add a breakpoint somewhere to stop your code, then in the console:
po FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).last!
You can then find an sqlite file in one of the subdirectories. It can be different, depending on iOS versions.
If you are using an App Group (or alternate method for standalone app)
If data is shared among multiple apps, the method above will not work. But you can also follow this method if you just did not find the sqlite file.
You can get Xcode to print the path:
- Open
Product > Scheme > Edit Scheme > Run > Arguments
- Add
-com.apple.CoreData.SQLDebug 1
argument in "Arguments Passed on launch"
Next time you launch the app, you should see something like this in the log output:
CoreData: annotation: Connecting to sqlite database file at /Users/***/Library/Developer/CoreSimulator/Devices/****/data/Containers/****/YourAppName.sqlite
As a bonus, you'll also get a bunch of other Core Data debug info.