iandundas / WidgetIntentNotUpdatingApp

4 stars 1 forks source link

Basic example

(more details below)

Showing that changes saved to SwiftData from a Widget AppIntent are not reflected in the main app.

https://github.com/iandundas/WidgetIntentNotUpdatingApp/assets/1131967/b6636fd6-9f8d-4f92-9eee-5ef99a38757a

TSI as submitted to Apple:

PLATFORM AND VERSION iOS Xcode 15.0.0 + iOS 17.0 (Simulator) and iPhone XR on iOS 17.0 (21A329).

DESCRIPTION OF PROBLEM

The problem, however, is that I cannot see this change in the main app when I foreground the app again.

The only way to see the new data is to force-quit the app and relaunch - and then I see the update.

I have tried using only the .mainContext, I have tried creating my own local Contexts both for reading and for writing, I have tried explicitly saving, I have tried letting it autosave. I have tried using @Query to automatically fetch the data, and I have tried manually fetching new data once the app comes to the foreground. In all cases I get stale data - it is as if the AppIntent had never been triggered.

Using the debugger I see that the expected paths are all followed, and no errors are thrown.

STEPS TO REPRODUCE I have a sample repo here, and the README has a video showing what happens: https://github.com/iandundas/WidgetIntentNotUpdatingApp

In the video you see:

So far so good.

Steps to reproduce: