---
title: "write(_:to:options:)"
framework: realitykit
role: symbol
role_heading: Type Method
path: "realitykit/entity/write(_:to:options:)"
---

# write(_:to:options:)

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

## Declaration

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

## Parameters

- `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

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 Elements of the entities array must have a non-empty 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:) 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. note: WriteError/missingSceneName 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.

## See Also

### Writing an entity to a file

- [write(to:options:)](realitykit/entity/write(to:options:).md)
- [Entity.WriteOptions](realitykit/entity/writeoptions.md)
- [Entity.WriteError](realitykit/entity/writeerror.md)
