Typically, the sqlite store file for core data apps is located in
Library>Application Support>iPhone Simulator>7.1(or whichever version you are using)>Applications>(Whichever folder contains your app)>Documents
folder, but I can't find it in IOS 8. I would assume they would just add an 8.0 folder inside the iPhone Simulator folder, but it's not there. Has anybody been able to locate it?
After new updates of Xcode I found that the sql files are now stored in new folder
/Library/Application Support
this could be a unique situation but if you did not found the sql files in document folder search them here:~/Library/Developer/CoreSimulator/Devices/[@device_id@]/data/Containers/Data/Application/[@application_id@]/Library/Application Support/
before it was stored in
Documents
folder:~/Library/Developer/CoreSimulator/Devices/[@device_id@]/data/Containers/Data/Application/[@application_id@]/Documents/
For
iOS 10.0+
you can usepersistentContainer.persistentStoreCoordinator.persistentStores.first?.url
I have created the Utility function that copies the sqlite file to your desired location (works only for simulator).
You can use it like
If you've already access to sqlite, shm and wal files then run the commands in the terminal to merge the WAL file into the sqlite file.
After running the above commands you can see the data in your sqlite file.
Here is definition of utility method for swift
For objective-c
Try this Simple 3 Step
Copy the following code in
didFinishLaunchingWithOptions
yourappdelegate.m
and add a break point before theNSLog()
Or in Swift:
2.Open Finder->Go -> Go to folder and paste the path copied from step 1
3. Yah!!! You are in your Destination.
I hacked this one-liner (Gist):
find ~/Library/Developer/CoreSimulator/Devices/ -name device.plist -exec sh -c "/usr/libexec/PlistBuddy -c \"print UDID\" '{}' | tr '\n' ' '" \; -exec sh -c "/usr/libexec/PlistBuddy -c \"print name\" '{}' | tr '\n' ' '" \; -exec sh -c "/usr/libexec/PlistBuddy -c \"print runtime\" '{}' | sed -n 's/com\.apple\.CoreSimulator.SimRuntime\.\(.*\)/\1/p'" \;
This prints:
Update:
As someone pointed out here, it is also possible to run
xcrun simctl list devices
to get a similar result:If you're using Swift, this will return the document directory's absolute path:
Swift 3.x
Locate didFinishLaunchingWithOptions function in your AppDelegate file and past this code there.