---
title: "loadAnchor(contentsOf:withName:)"
framework: realitykit
role: symbol
role_heading: Type Method
path: "realitykit/entity/loadanchor(contentsof:withname:)"
---

# loadAnchor(contentsOf:withName:)

Synchronously loads an anchor entity from a file URL.

## Declaration

```swift
@MainActor @preconcurrency static func loadAnchor(contentsOf url: URL, withName resourceName: String? = nil) throws -> AnchorEntity
```

## Parameters

- `url`: A file URL representing the file to load.
- `resourceName`: A unique name the method assigns to the resource it loads, for use in network synchronization.

## Return Value

Return Value The root entity in the loaded file, which Reality Kit casts as an AnchorEntity.

## Discussion

Discussion Loading an Entity with this method blocks the main actor because it’s synchronous, so only call it from a command-line application. The method can stall a regular app, which makes it visibly hitch, and the system terminates an app if its UI becomes unresponsive. See init(named:in:) for an example that demonstrates how to safely load content.

## See Also

### Loading an anchor entity

- [loadAnchor(named:in:)](realitykit/entity/loadanchor(named:in:).md)
- [loadAnchorAsync(named:in:)](realitykit/entity/loadanchorasync(named:in:).md)
- [loadAnchorAsync(contentsOf:withName:)](realitykit/entity/loadanchorasync(contentsof:withname:).md)
