I have two apps that share data through an App Group. However, I’ve noticed that when one of the apps is uninstalled, the shared Core Data model is also uninstalled. If I don't create a shared model in one of the apps, I cannot access the data. What should I do to resolve this issue?
How to Access Core Data from Another App via App Group
If "the shared Core Data model" in your description means the .xcdatamodeld
file (or document package) in your project, which contains the data schema, and is typically called a Core Data model, all your apps need to be built with it to be able to load an existing shared store.
If "the shared Core Data model" actually means the shared Core Data store, which contains the data, the behavior should be this:
-
On iOS, removing an app from a device will clear its app group container, if the app is the last one on the device that uses container. If another app or extension that uses the container still exists on the device, the system will not clear the container.
-
On macOS, removing an app does not clear its app group container.
If you see any behavior different from what I described, please share the details about how you observe the behavior. I'd take a closer look.
Best,
——
Ziqiao Chen
Worldwide Developer Relations.
I saw your comments yet don't have more to say based on what you described. If you can provide the detailed steps to elaborate what you did and how you observed the issue, folks in the forums may be able to comment. See tips on writing forums posts, if necessary.
Best,
——
Ziqiao Chen
Worldwide Developer Relations.