<!--
{
  "availability" : [
    "iOS: -",
    "iPadOS: -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/AttachmentContentBuilder",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "RealityKit",
      "SwiftUI"
    ],
    "preciseIdentifier" : "s:19_RealityKit_SwiftUI24AttachmentContentBuilderV"
  },
  "title" : "AttachmentContentBuilder"
}
-->

# AttachmentContentBuilder

A result builder that creates attachment content from closures.

```
@resultBuilder struct AttachmentContentBuilder
```

## Overview

The `buildBlock` methods in this type create [`AttachmentContent`](/documentation/RealityKit/AttachmentContent)
instances based on the number and types of sources provided as parameters.

RealityKit calls this builder for you when SwiftUI annotates the `attachment`
parameter of some [`RealityView`](/documentation/RealityKit/RealityView) initializers that have the
`@AttachmentContentBuilder` annotation.

## Topics

### Type Methods

[`static func buildBlock() -> EmptyAttachmentContent`](/documentation/RealityKit/AttachmentContentBuilder/buildBlock())

Creates an empty attachment content containing no statements.

[`static buildBlock(_:)`](/documentation/RealityKit/AttachmentContentBuilder/buildBlock(_:))

Creates a single content result.

[`static func buildEither<TrueContent, FalseContent>(first: TrueContent) -> ConditionalAttachmentContent<TrueContent, FalseContent>`](/documentation/RealityKit/AttachmentContentBuilder/buildEither(first:))

Provides support for “if” statements in multi-statement closures,
producing conditional content for the “then” branch.

[`static func buildEither<TrueContent, FalseContent>(second: FalseContent) -> ConditionalAttachmentContent<TrueContent, FalseContent>`](/documentation/RealityKit/AttachmentContentBuilder/buildEither(second:))

Provides support for “if-else” statements in multi-statement closures,
producing conditional content for the “else” branch.

[`static func buildExpression<Content>(Content) -> Content`](/documentation/RealityKit/AttachmentContentBuilder/buildExpression(_:))

Builds an expression within the builder.

[`static func buildIf<Content>(Content?) -> Content?`](/documentation/RealityKit/AttachmentContentBuilder/buildIf(_:))

Provides support for “if” statements in multi-statement closures,
producing an optional view that is visible only when the condition
evaluates to `true`.

[`static func buildLimitedAvailability(any AttachmentContent) -> some AttachmentContent`](/documentation/RealityKit/AttachmentContentBuilder/buildLimitedAvailability(_:))

Provides support for “if” statements with `#available()` clauses in
multi-statement closures, producing conditional content for the “then”
branch, i.e. the conditionally-available branch.

---

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)