Widgetkit's getTimeline is causing crash at completion(timeline)

I was debugging my widget in iOS 17.0 (21A5312c)

It is constantly crashing in getTimeline when calling completion(timeline)

The same code was working in previous betas.

I've checked the debugger, neither completion nor timeline is nil but I get a EXC_BAD_ADDRESS crash

As a result the widgets are always white.

How to fix?

Post not yet marked as solved Up vote post of dyyi Down vote post of dyyi
765 views

Replies

ok when I did more troubleshooting, it turns out this line causes a crash

@Environment(.showsWidgetContainerBackground) var showBG : Bool

You should use @Environment(\.showsWidgetContainerBackground) var showBG, omitting : Bool.

@darkpaw why would that make a difference? I'm confused. The variable is indeed a bool otherwise compiler wont let it

Seems like a bug in Beta 6 (FB12974903). Look here: https://mastodon.social/@_Davidsmith/110897587368893341

This issue is fixed for me with Xcode 15 Beta 7 for iOS 17 Beta 7 AND iOS 16.6 Release. Great news!