Implementing Dynamic Island support - Generic parameter 'Expanded' could not be inferred

460 Views Asked by At

I'm following Displaying live data with Live Activities and adding support for the Dynamic Island in an app with an existing widgets extension. However, I'm unable too get it to build

import SwiftUI
import WidgetKit


@main
struct PizzaDeliveryActivityWidget: Widget {
    var body: some WidgetConfiguration {
        ActivityConfiguration(for: PizzaDeliveryAttributes.self) { context in
            // Create the presentation that appears on the Lock Screen and as a
            // banner on the Home Screen of devices that don't support the
            // Dynamic Island.
            // ...
        } dynamicIsland: { context in
            // Create the presentations that appear in the Dynamic Island.
            // ...
        }
    }
}

as I get the errors

Generic parameter 'Expanded' could not be inferred

and

Result builder 'DynamicIslandExpandedContentBuilder' does not implement any 'buildBlock' or a combination of 'buildPartialBlock(first:)' and 'buildPartialBlock(accumulated:next:)' with sufficient availability for this call site

This is even if I supply a dynamicIsland closure of

            DynamicIsland {
                EmptyView()
            } compactLeading: {
                EmptyView()
            } compactTrailing: {
                EmptyView()
            } minimal: {
                EmptyView()
            }

What am I missing? My project's minimum deployment target is iOS 16.1.

1

There are 1 best solutions below

0
renevdkooi On

I fixed my issue by adding the following above the widget declaration @available(iOS 16.2, *)

(Yes 16.2), it has something to do with the context.isStale bit.