One Logo Pool Ball
AppIntents · IOS API REFERENCE

AppEntity

protocol · iOS 16.0+ · SDK 27.1

protocol AppEntity : AppValue, DisplayRepresentable, Identifiable where Self == Self.ValueType, Self.ID : EntityIdentifierConvertible, Self.ID : Sendable

An interface for making a custom type or app-specific concept discoverable by Apple Intelligence and experiences like Siri or the Shortcuts app. To use a data model object to app intents, update it to conform to the `AppEntity` protocol. Declare properties using the `@Property` property wrapper to make them visible to the system. The following example from the <doc:AcceleratingAppInteractionsWithAppIntents> sample app shows a data model for a trail: ```swift struct TrailEntity: AppEntity { // Provide the system with the interface required to query `TrailEntity` structures. static let defaultQuery = TrailEntityQuery() // The system requires the `AppEntity` identifier to be unique and persistant because the system may save it in a shortcut. var id: Trail.ID @Property var name: String @Property(title: "Region") var regionDescription: String @Property var trailLength: Measurement<UnitLength> var imageName: String var currentConditions: String /** Information on how to display the entity to people — for example, a string like the trail name. Include the optional subtitle and image for a visually rich display. */ var displayRepresentation: DisplayRepresentation { DisplayRepresentation(title: "\(name)", subtitle: "\(regionDescription)", image: DisplayRepresentation.Image(named: imageName)) } init(trail: Trail) { self.id = trail.id self.imageName = trail.featuredImage self.currentConditions = trail.currentConditions self.name = trail.name self.regionDescription = trail.regionDescription self.trailLength = trail.trailLength } } extension TrailEntity: URLRepresentableEntity { static var urlRepresentation: URLRepresentation { // Use string interpolation to fill values from your entity necessary for constructing the universal link URL. // This example URL uses the unique and persistant identifier for the `TrailEntity` in the URL. "https://example.com/trail/\(.id)/details" } } ``` It is up to you whether you want to conform to the `AppEntity` protocol directly on the data models of your app, or if you create data models specific to your app intents implementation. In many cases, it's a good idea to create models specific to app intents that shadow your app data models to keep entities separate from the rest of your app's logic. > Important: `AppEntity` instances have a total size limit of 10 MB, including all child properties and their values. > If your entity exceeds this limit, the system throws an exception, and your app might crash. > To reduce the size of your app entity, use the `@DeferredProperty` > property wrapper. For more information, > see <doc://com.apple.documentation/documentation/appintents/defining-app-entities-for-your-custom-data-types>.

Members (2)

get · iOS 16.0+

displayRepresentation

Swift declaration
var displayRepresentation: DisplayRepresentation { get }

The visual elements to display when presenting an instance of the type.

get · iOS 16.0+

id

Swift declaration
var id: Self.ID { get }

The stable identity of the entity associated with this instance.

Skipped declarations

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

AppEntity.defaultResolverSpecification

This protocol needs associated types that cannot yet cross the bridge.

AppEntity.defaultResolverSpecification

This protocol needs associated types that cannot yet cross the bridge.

AppEntity.defaultQuery

This protocol needs associated types that cannot yet cross the bridge.

All AppIntents types →