Partial fix for widgets & complications not showing correctly

I recently raised this post explaining how I couldn't seem to get watchOS 9 complications to work, and I've figured out a partial fix.

The original post details the issues with complications - and some are still valid - but this fix applies to both my complications and Home Screen / Lock Screen widgets.

I was following the various WWDC 2020/2022 videos and the Emoji Rangers sample code, adding bits here and there, and assuming they were completely valid. Sadly, this bit of code in the widget's dynamic intents IntentTimelineProvider getTimeline really just banjaxed everything:

// Create entries for one day, 15 minutes apart
let currentDate = Date()
for minuteOffset in stride(from: 0, to: 60 * 60 * 24, by: 15) {
	let entryDate = Calendar.current.date(byAdding: .minute, value: minuteOffset, to: currentDate)!
	entries.append(EventEntry(date: entryDate, event: event))
}

If I remove that, and generate a different timeline with specific dates and times (for example: now, in 10 mins, in 2 hours, in a day, etc.) the complications appear correctly, as do Home Screen and Lock Screen widgets.

The outstanding issues with complications are:

  1. The previews all use the same data, but getSnapshot() is supposed to return the data specific to that event from the configuration, i.e. if let theId = configuration.event?.identifier. "Christmas" is correct, but "Gallery Opening" is using Christmas's data.

  1. Once I've selected the event I want to use in a complication the edit screen shows it as totally blank, not even a placeholder:

I hope this little fix works for you guys. And, if you know how to fix the above issues, let me know.

(iOS 16.1 beta 1, Xcode 14.1 beta 1)

I had already answered these questions on other question which author still you. Maybe you can try like this:

1.For question one, I'm also having this problem, and code is right definitely. Finally resolved by upgrading the watchOS version. Now watchOS version upgrade to 9.1(20S75) from 9.0.xx. ( iOS Version is 16.0, Xcode version is 14.0.)

2.When edit the complication, getSnapshot will called and return the entry. In my situation, the logic in getSnapshot and getTimeline almost same, except return different value. So you can try.

Partial fix for widgets & complications not showing correctly
 
 
Q