<!--
{
  "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/write(_:to:options:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation6EntityC5write_2to7optionsySayACG_0B03URLVAC12WriteOptionsVtYaKFZ"
  },
  "title" : "write(_:to:options:)"
}
-->

# write(_:to:options:)

Exports an array of entities as separate scenes within a single RealityKit file.

```
nonisolated(nonsending) static func write(_ entities: [Entity], to url: URL, options: Entity.WriteOptions = WriteOptions()) async throws
```

## Parameters

`entities`

An array of named entities to be written as separate scenes in the Reality file.

`url`

The location URL in the file system where you want to save the `.reality` file.

`options`

Options for writing the Reality file, such as texture compression settings.

## Discussion

This method generates a file with a `.reality` suffix,
automatically setting its compatibility with other systems based on all the entity tree contents.
The entities and their children may contain components or assets that can require the resulting RealityKit file
to be compatible with system versions between:

- iOS 18 or later
- macOS 15 or later
- visionOS 2 or later
- tvOS 26 or later

Elements of the `entities` array must have a non-empty [`name`](/documentation/RealityKit/Entity/name) property.
Each name must be unique within the array to allow unambiguous scene loading.

After writing, individual scenes can be loaded using the [`init(contentsOf:withName:)`](/documentation/RealityKit/Entity/init(contentsOf:withName:)) initializer
with the entity’s name as the scene identifier.

Logs with the prefix [RealityKit File Compatibility Info] will be posted to the console
whenever a component or asset requires a compatibility adjustment.

> Throws: An error if any entity in the array has an empty name.

> Important:
> During its initial setup phase, this method can indirectly block the main thread,
> and also has the potential to block it for the full duration of the call if the system
> has additional work it needs to do there.

---

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)