<!--
{
  "availability" : [
    "iOS: 27.0.0 -",
    "iPadOS: 27.0.0 -",
    "macCatalyst: -",
    "macOS: 27.0.0 -",
    "tvOS: 27.0.0 -",
    "visionOS: 27.0.0 -",
    "watchOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AppIntents",
  "identifier" : "/documentation/AppIntents/SyncableEntityIdentifier",
  "metadataVersion" : "0.1.0",
  "role" : "Structure",
  "symbol" : {
    "kind" : "Structure",
    "modules" : [
      "App Intents"
    ],
    "preciseIdentifier" : "s:10AppIntents24SyncableEntityIdentifierV"
  },
  "title" : "SyncableEntityIdentifier"
}
-->

# SyncableEntityIdentifier

A type-safe wrapper you use to specify different local and stable identifiers for an entity.

```
struct SyncableEntityIdentifier<LocalID, StableID> where LocalID : EntityIdentifierConvertible, LocalID : Sendable, StableID : EntityIdentifierConvertible, StableID : Sendable
```

## Overview

Use this structure if you maintain separate local and stable identifiers in one of your entity types. Assign this structure to the `id` property
of your entity and use the value in the [`local`](/documentation/AppIntents/SyncableEntityIdentifier/local) property to refer to the entity in your code. The
system uses the [`stable`](/documentation/AppIntents/SyncableEntityIdentifier/stable) value to refer to the same entity during operations that occur on another device.

When referring to an entity in your code, you can refer to this type directly. The following example shows an entity that uses this type for its
identifier. The query object for the entity similarly refers to this type directly in methods.

```swift
struct Photo: AppEntity, SyncableEntity {
    var id: SyncableEntityIdentifier<String, String>
    var creationDate: Date
}

struct PhotoQuery: EntityQuery {
    func entities(for ids: [SyncableEntityIdentifier<String, String>]) async throws -> [Photo] {
        // Works everywhere - queries, entities, helper functions
    }
}
```

For additional information about how to use this type, see [`SyncableEntity`](/documentation/AppIntents/SyncableEntity).

## Topics

### Initializers

[`init(id: LocalID)`](/documentation/AppIntents/SyncableEntityIdentifier/init(id:))

Creates an identifier where the local and stable IDs are identical.

[`init(local: LocalID, stable: StableID)`](/documentation/AppIntents/SyncableEntityIdentifier/init(local:stable:))

Creates an identifier with both local and stable IDs.

### Instance Properties

[`let local: LocalID?`](/documentation/AppIntents/SyncableEntityIdentifier/local)

The identifier you use to refer to the entity on the current device.

[`let stable: StableID?`](/documentation/AppIntents/SyncableEntityIdentifier/stable)

The identifier you use to refer to the entity across devices.

### Default Implementations

[EntityIdentifierConvertible Implementations](/documentation/AppIntents/SyncableEntityIdentifier/EntityIdentifierConvertible-Implementations)

[Equatable Implementations](/documentation/AppIntents/SyncableEntityIdentifier/Equatable-Implementations)

[Hashable Implementations](/documentation/AppIntents/SyncableEntityIdentifier/Hashable-Implementations)

## Relationships

### Conforms To

[`Equatable`](/documentation/Swift/Equatable)

[`EntityIdentifierConvertible`](/documentation/AppIntents/EntityIdentifierConvertible)

[`Escapable`](/documentation/Swift/Escapable)

[`Copyable`](/documentation/Swift/Copyable)

[`SendableMetatype`](/documentation/Swift/SendableMetatype)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

[`Sendable`](/documentation/Swift/Sendable)

[`Hashable`](/documentation/Swift/Hashable)

---

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)