<!--
{
  "availability" : [
    "iOS: 14.0.0 -",
    "iPadOS: 14.0.0 -",
    "macCatalyst: 14.0.0 -",
    "macOS: 11.0.0 -",
    "tvOS: 14.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 7.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "DeveloperToolsSupport",
  "identifier" : "/documentation/DeveloperToolsSupport/LibraryContentBuilder",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "DeveloperToolsSupport"
    ],
    "preciseIdentifier" : "s:21DeveloperToolsSupport21LibraryContentBuilderV"
  },
  "title" : "LibraryContentBuilder"
}
-->

# LibraryContentBuilder

A function builder for generating arrays of library items without
requiring full array literal syntax.

```
@resultBuilder struct LibraryContentBuilder
```

## Overview

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 [`views`](/documentation/DeveloperToolsSupport/LibraryContentProvider/views)
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())
    }
}
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)