One Logo Pool Ball
AppIntents · IOS API REFERENCE

EntityIdentifier

struct · iOS 16.0+ · SDK 27.1

struct EntityIdentifier

A type that uniquely identifies a specific instance of an app entity. The value used should be unique across all entities of the given type. Entities which are relevant across executions of the application should have stable identifiers that persist across executions. Entities, by default, conform to the ``Identifiable`` protocol. Use a type for the `id` that conforms to ``EntityIdentifierConvertible``. Default implementations for `String`, `UUID` and `Int` are provided. For example: ``` struct Song: AppEntity { let id = UUID() } ``` ## Cross-Device Stable Identifiers For entities that adopt ``_SyncableEntity``, the framework automatically extracts stable identifiers for cross-device session syncing: - **Passthrough case**: If your entity's ID is already stable across devices (like server UUIDs), just adopt ``_SyncableEntity`` with no other changes. The framework uses your ID as both the local and stable identifier. - **Mapped case**: If your entity has different local and stable identifiers, use ``_SyncableEntityIdentifier`` as your ID type. The framework extracts the stable ID from the wrapper. - **Custom identifier case**: If your entity uses a custom ID type that conforms to ``_SyncableEntityIdentifierProviding``, the framework extracts the stable ID via the protocol's `stableIdentifierString` property. Apps never interact with `EntityIdentifier.stableIdentifier` directly - they work with their entity's ID type (plain types like `UUID`, ``_SyncableEntityIdentifier`` for mapped IDs, or custom types conforming to ``_SyncableEntityIdentifierProviding``). The stable identifier is NOT used for equality or hashing - two `EntityIdentifier` instances are equal if they have the same type and local identifier, regardless of stable identifier value.

Members (6)

init · iOS 18.0+

init

TypeScript
static init(activityIdentifier: string): (EntityIdentifier) | null
Swift declaration
init?(activityIdentifier: String)
get · iOS 16.0+

identifier

TypeScript
get identifier(): string
Swift declaration
let identifier: String

Value uniquely identifying the entity instance within its type.

get · iOS 16.0+

description

TypeScript
get description(): string
Swift declaration
var description: String { get }

A textual representation of this instance. Calling this property directly is discouraged. Instead, convert an instance of any type to a string by using the `String(describing:)` initializer. This initializer works with any type, and uses the custom `description` property for types that conform to `CustomStringConvertible`: struct Point: CustomStringConvertible { let x: Int, y: Int var description: String { return "(\(x), \(y))" } } let p = Point(x: 21, y: 30) let s = String(describing: p) print(s) // Prints "(21, 30)" The conversion of `p` to a string in the assignment to `s` uses the `Point` type's `description` property.

get · iOS 16.0+

valueMaximumLength

TypeScript
static get valueMaximumLength(): number
Swift declaration
static let valueMaximumLength: Int

Maximum allowed length for the `identifier` value. This is a constraint imposed by the system and thus forces us to truncate the identifier if it exceeds the maximum length.

get · iOS 16.0+

defaultResolverSpecification

TypeScript
static get defaultResolverSpecification(): EmptyResolverSpecification<EntityIdentifier>
Swift declaration
static var defaultResolverSpecification: EmptyResolverSpecification<EntityIdentifier>
set · iOS 16.0+

defaultResolverSpecification

TypeScript
static set defaultResolverSpecification(value: EmptyResolverSpecification<EntityIdentifier>)
Swift declaration
static var defaultResolverSpecification: EmptyResolverSpecification<EntityIdentifier>

Skipped declarations

3 declarations were excluded from these bindings. Each reason comes from the generator or the iOS SDK compiler.

EntityIdentifier.entityType

Passing a Swift type itself is not supported.

EntityIdentifier.init(for:)

This declaration needs Swift generic type arguments. (no canonical witness for Entity)

EntityIdentifier.init(for:identifier:)

Passing a Swift type itself is not supported.

All AppIntents types →