One Logo Pool Ball
DeveloperToolsSupport · IOS API REFERENCE

LibraryContentBuilder

struct · iOS 14.0+ · SDK 27.1

@resultBuilder struct LibraryContentBuilder

A function builder for generating arrays of library items without requiring full array literal syntax. Use the library content function builder to simplify the implementation of protocol requirements from you which provide arrays of library items. For example, without the builder, you would have to explicitly put items in an array in a ``LibraryContentProvider/views-25pdm`` implementation: struct LibraryViewContent: LibraryContentProvider { var views: [LibraryItem] { [ LibraryItem(MyFirstView()), LibraryItem(MySecondView()) ] } } With the builder, you can omit the array literal syntax: struct LibraryViewContent: LibraryContentProvider { @LibraryContentBuilder var views: [LibraryItem] { LibraryItem(MyFirstView()) LibraryItem(MySecondView()) } } In practice, the Swift compiler infers the need for a library content builder attribute and adds it at build time, so that you never need to explicitly write the attribute in your code, even though it's technically in use: struct LibraryViewContent: LibraryContentProvider { var views: [LibraryItems] { LibraryItem(MyFirstView()) LibraryItem(MySecondView()) } }

Members (2)

static · iOS 14.0+

buildExpression

TypeScript
static buildExpression(item: LibraryItem): Array<LibraryItem>
Swift declaration
static func buildExpression(_ item: LibraryItem) -> [LibraryItem]
static · iOS 14.0+

buildExpression

TypeScript
static buildExpression84173(items: Array<LibraryItem>): Array<LibraryItem>
Swift declaration
static func buildExpression(_ items: [LibraryItem]) -> [LibraryItem]

Skipped declarations

1 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

LibraryContentBuilder.buildBlock(_:)

A variable number of Swift arguments is not supported.

All DeveloperToolsSupport types →