I'll preface this to say that I'm not 100% sure this is all accurate, but I wanted to share this problem I was seeing developing a widget for a SwiftUI app in case it helps someone else get to a solution faster.
Two weeks ago I released a version of an app which contained a brand new widget. For the kind
property of the widget's configuration I just used something generic: AppWidget.
Last week we wanted to add an additional widget into the app and I realized that I ought to make the kind
be a little more specific. So I renamed the first kind from AppWidget to DailyPromptWidget ... and made the second widget use a kind named DailyCheckInWidget.
Then, we started seeing issues where the widget wasn't responding to taps and would eventually go blank. I could add in a new widget to the home screen and that'd work fine. Searching the Internet for ideas yielded nothing.
I connected my iPhone to my Mac and launched the Console app and then started tapping on the non-responsive widget. I discovered a few output messages like this:
Timeline[my.bundle.id::my.bundle.id.widgetid:AppWidget:systemMedium::338.00/158.00/21.60:(null)]--CD0C49416486::0xc46382000) Unable to create CHUISWidgetLaunchRequest without a effectiveContainerBundleIdentifier
I was able to reproduce the issue by renaming the bundle ID of the widget (and leaving the working widget on the home screen). Tapping it gave the same exact error.
Another error, which clued me in more:
Content load failed: unable to find or unarchive file for key: [my.bundle.id.widgetid:AppWidget:systemMedium::338.00/158.00/21.60:(null)] on no host. The session may still produce one shortly. Error: Using url `file:///private/var/mobile/Containers/Data/PluginKitPlugin/012DB9D2-07F7-4383-9CCE-B040652B7999/SystemData/com.apple.chrono/placeholders/AppWidget/systemMedium----338.00w--158.00h--21.60r--0f--0.00t-0.00l-0.00b0.00t.chrono-timeline` ... Error Domain=NSCocoaErrorDomain Code=4 "The file "systemMedium----338.00w--158.00h--21.60r--0f--0.00t-0.00l-0.00b0.00t.chrono-timeline" doesn't exist." UserInfo={NSFilePath=/private/var/mobile/Containers/Data/PluginKitPlugin/012DB9D2-07F7-4383-9CCE-B040652B7999/SystemData/com.apple.chrono/placeholders/AppWidget/systemMedium----338.00w--158.00h--21.60r--0f--0.00t-0.00l-0.00b0.00t.chrono-timeline, NSUnderlyingError=0x3025a1d10 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
So, I tried finding those files in the simulator data on my Mac. Inside the placeholders/
directory are directories with the names of all the widget kind
I had used (the old and the new). Inside those named kind directories are, what look to be, files representing each timeline entry.
It appears that if you change the kind
string in your widget's configuration, the widget you've added to your home screen does not get updated and will continue looking for the old timeline entry files in the original kind
directory.
The solution? Either don't rename the kind
once you've released it on the App Store, or instruct customers to remove the widget and add it back after they've installed your app update.
It'd be nice if an app update would also update the kind
directory name.