<!--
{
  "availability" : [
    "iOS: 18.0.0 -",
    "iPadOS: 18.0.0 -",
    "macCatalyst: 18.0.0 -",
    "macOS: 15.0.0 -",
    "tvOS: 26.0.0 -",
    "visionOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "RealityKit",
  "identifier" : "/documentation/RealityKit/Entity/write(to:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "RealityKit"
    ],
    "preciseIdentifier" : "s:17RealityFoundation6EntityC5write2toy0B03URLV_tYaKF"
  },
  "title" : "write(to:)"
}
-->

# write(to:)

Exports the entity as a RealityKit file to a location in the file system.

```
@MainActor func write(to url: URL) async throws
```

## Parameters

`url`

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

## Discussion

This method generates a file with a `.reality` suffix,
automatically setting its compatibility with other systems based on the Entity’s tree content.
The Entity and its 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

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

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