shallowThought shallowThought - 27 days ago 10
iOS Question

How to get Core Datas sqlite store file for iMessage extension

We are developing an iMessage extension. It uses Core Data successfully. We need to evaluate the store.sqlite file, but can not find it.

We try to find it like this:


  • In Xcode: Window -> Devices

  • In
    Installed Apps
    , select our extension

  • Download Container ...



But the container is empty:



Question: where to find store.sqlite file?




Update:

Extensiton seem to default write to
file:///var/mobile/Containers/Data/PluginKitPlugin/
.

file:///var/mobile/Containers/Data/PluginKitPlugin/B86BD789-D868-45BE-AA8B-C76C623CA85B/Library/Application%20Support/store.sqlite

Answer

The actual sqlite file is likely to be in a shared container.

What works for me is to log the store URL and use that to locate it:

print(container.persistentStoreCoordinator.persistentStores.first!.url!)

Yields something like

file:///Users/developer/Library/Developer/CoreSimulator/Devices/2EAE0CD4-7899-45A3-8E83-E7D79DEEA08F/data/Containers/Data/Application/37F48A5E-7DAB-4E30-A752-F5B62826A15A/Library/Application%20Support/Events.sqlite

Comments