Contents

Preview(_:widget:relevanceProvider:relevance:)

Preview a widget with a relevance configuration, using the specified relevances.

Declaration

@freestanding(declaration) macro Preview<Widget, Provider>(_ name: String? = nil, widget: @escaping @MainActor () -> Widget, relevanceProvider: @escaping @MainActor () -> Provider, relevance: @escaping @MainActor () async -> WidgetRelevance<Provider.Configuration>) where Widget : Widget, Provider : RelevanceEntriesProvider

Parameters

  • name:

    An optional display name for the preview that appears in the Xcode preview canvas.

  • widget:

    A closure producing the widget to be previewed.

  • relevanceProvider:

    A closure producing the relevance provider that generates the preview’s entries.

  • relevance:

    A closure producing the relevance that the relevance provider uses.

Overview

Provide the relevance provider with sample data and use it to step through relevance entries in the Xcode proview canvas.

See Also

Generating a widget preview