<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: 27.0.0 -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/Entity/ComponentSet/set(qualifiedComponentName:representation:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation6EntityC12ComponentSetV3set09qualifiedD4Name14representationySS_xtKSERzlF"
  },
  "title" : "set(qualifiedComponentName:representation:)"
}
-->

# set(qualifiedComponentName:representation:)

Adds component data to an entity that is written to a Reality file but has no other effect at author time.

```
@MainActor @preconcurrency func set(qualifiedComponentName: String, representation: some Encodable) throws
```

## Parameters

`qualifiedComponentName`

The component’s fully qualified, module-qualified name.

`representation`

A value that encodes to the component’s expected layout.

## Discussion

Use this function from an authoring tool to serialize a component whose Swift type isn’t available on the
authoring platform. `representation` is encoded into any Reality file this entity is written to, and is decoded
back into a [`Component`](/documentation/RealityKit/Component) of the type named by `qualifiedComponentName` when that file is loaded, so it must
encode to the layout that component expects. For runtime use on a platform where the component’s Swift type is
available, set the component directly with `set(_:)` instead.

```swift
// Serialize a custom component by its fully qualified name.
struct MyCustomComponent: Component, Codable {
    var intensity: Float
}
try entity.components.set(
    qualifiedComponentName: "MyModule.MyCustomComponent",
    representation: MyCustomComponent(intensity: 0.5))
```

> Throws: An error if `representation` can’t be encoded, or if `qualifiedComponentName` uses a reserved prefix.

---

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)