Be careful changing a widget's "kind" configuration

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.

We are experiencing the same issue with our app. However, for us, it's not caused by changing the "kind", but only after an app update in which there were no changes regarding the widget. Just after it updated, the widget turns black in some cases. It also appears black in the widget gallery. Removing and adding it again did not work in this case, only after an iOS restart it works fine again.

I am seeing a similar error in console:

Content load failed: unable to find or unarchive file for key: [my.bundle.id::my.bundle.id.widget:MyWidget:systemSmall::158.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/A1582067-2483-4B92-B1E4-A35F5BBA0DF7/SystemData/com.apple.chrono/placeholders/MyWidget/systemSmall----158.00w--158.00h--21.60r--0f--0.00t-0.00l-0.00b0.00t.chrono-timeline` ... Error Domain=NSCocoaErrorDomain Code=4 "Die Datei „systemSmall----158.00w--158.00h--21.60r--0f--0.00t-0.00l-0.00b0.00t.chrono-timeline“ existiert nicht." UserInfo={NSFilePath=/private/var/mobile/Containers/Data/PluginKitPlugin/A1582067-2483-4B92-B1E4-A35F5BBA0DF7/SystemData/com.apple.chrono/placeholders/MyWidget/systemSmall----158.00w--158.00h--21.60r--0f--0.00t-0.00l-0.00b0.00t.chrono-timeline, NSUnderlyingError=0x3003fdfb0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

And I also see this one:

Two equal instances have unequal identities. <xpcservice<my.bundle.id.widget([osservice<com.apple.chronod>:132])>> and <xpcservice<my.bundle.id.widget([osservice<com.apple.chronod>:132])>>

Is there a way to fix it? Using iOS 17.4

it happened to my app too. App updates crash the widget and the only solution is to restart the device which leads to angry users and bad reviews

In my case some of the widgets get completely removed for the home screen automatically at random time. I also noticed the following in the console:

[...] systemMedium::(null)

Did some of view also get this problem of "automatically removed" widget from the OS? I am running iOS 17.5 (also same behaviour with 17.4).

Be careful changing a widget's "kind" configuration
 
 
Q