Sample CodeiOS, iPadOS, Mac Catalyst, macOSReviewed 2026-07-21View on Apple Developer

Adopting App Intents to support system experiences

At a glance

Item Summary
Purpose Create app intents and entities so people can use your app’s content and actions across system experiences.
App architecture A Swift sample with the source-visible chain AppIntentsTravelTrackingContentViewSharedDataStoreGalleryTimelineProviderAppIntents APIs.
Main patterns Protocol-oriented abstraction, Delegate or data-source callbacks, Central store, Binding-based state propagation, Actor isolation
Project style 98 scanned source file(s) across Swift, organized around ranked entry, type, and file boundaries.
Execution model Source-visible boundaries: await suspension point, Task, Sendable or @Sendable, @MainActor, MainActor.run; none alone proves a background thread.
State/event model Source-visible mechanisms: SwiftUI state property wrapper, @Observable.
Key frameworks/packages TravelTrackingCore, AppIntents, SwiftUI, TravelTrackingIntents, Foundation; these are source dependencies, not architecture labels.

Project structure

Source bundle/
└── AppIntentsTravelTracking/
    ├── AppIntentsTravelTracking/
    │   ├── AppIntentsTravelTracking.swift
    │   └── Views/
    │       ├── ContentView.swift
    │       └── Photos/
    │           └── Photo/
    │               ├── PhotoDetailInspectorView.swift
    │               └── PhotoDetailView.swift
    ├── TravelTrackingShared/
    │   └── Sources/
    │       ├── TravelTrackingCore/
    │       │   └── Persistence/
    │       │       └── SharedDataStore.swift
    │       ├── TravelTrackingIntents/
    │       │   └── Entities/
    │       │       ├── PhotoEntity.swift
    │       │       ├── PhotoAlbumEntity.swift
    │       │       ├── LandmarkCollectionEntity.swift
    │       │       └── LandmarkEntity.swift
    │       └── TravelTrackingSnippets/
    │           └── FindTickets/
    │               ├── SearchEngine.swift
    │               └── SearchRequestEntity.swift
    └── TravelGalleryWidget/
        └── TravelGalleryWidgetBundle.swift

Structure observations

  • Architecturally prominent files are ranked from entry points and role-named declarations; resource-only paths are omitted.
  • Primary languages: Swift.
  • The verified tree contains 7 project/configuration file(s) and 123 source declaration(s).

Overall architecture

Reference code

AppIntentsTravelTracking/AppIntentsTravelTracking/AppIntentsTravelTracking.swift:15 — architecture anchor

@main
struct AppIntentsTravelTrackingApp: App {
    @State private var modelData = ModelData()
    // ...
}

Interpretation

The arrows summarize the source-visible entry, role-named types or folders, and framework direction; when nodes come from structural folders, the sequence is a high-level interpretation rather than proof that every adjacent node calls the next. Ownership is claimed only where the next section cites a stored property or assignment. The diagram is intentionally limited to the dominant path into App Intents.

Ownership and state

Ownership evidence

AppIntentsTravelTracking/AppIntentsTravelTracking/AppIntentsTravelTracking.swift:17 — stored dependency or nearest verified ownership anchor

@main
struct AppIntentsTravelTrackingApp: App {
    @State private var modelData = ModelData()
    // ...
}
Owner Object or state Relationship Mutation authority
AppIntentsTravelTrackingApp ModelData (modelData) owns wrapper-managed state Owning lexical scope
CollectionsSectionPicker CollectionsSection (selection) borrows mutable state The upstream binding owner is authoritative
CollectionsTab CollectionsSection (section) owns wrapper-managed state Owning lexical scope
PhotoDetailInspectorView TravelPhoto (photo) stores or receives Initialized by the owner; the binding is immutable

Composition arrows indicate a source-visible construction expression or locally owned value state; aggregation means the owner stores or receives a dependency without proving exclusive lifetime ownership.

Concurrency, scheduling, and thread safety

Evidence limit: actor isolation, async/await, or Task creation does not by itself prove background-thread execution; Sendable conformance alone does not prove thread-safe mutation.

Concern Source mechanism Verified placement or handoff Evidence
Suspension boundary await suspension point The source declares or crosses an asynchronous boundary; it does not by itself establish background execution. AppIntentsTravelTracking/AppIntentsTravelTracking/AppIntentsTravelTracking.swift:36
Task creation Task The source creates an unstructured task; surrounding context determines inherited actor isolation. AppIntentsTravelTracking/AppIntentsTravelTracking/Views/ContentView.swift:61
Transfer contract Sendable or @Sendable The source declares a sendability boundary; this alone does not synchronize mutable state. AppIntentsTravelTracking/TravelTrackingShared/Sources/TravelTrackingCore/Models/Landmark.swift:11
Main isolation @MainActor The cited annotation marks its attached declaration or closure as main-actor isolated. AppIntentsTravelTracking/TravelTrackingShared/Sources/TravelTrackingCore/Models/TravelCollection.swift:20
Main isolation MainActor.run The cited operation explicitly enters a main-actor-isolated region. AppIntentsTravelTracking/TravelTrackingShared/Sources/TravelTrackingCore/Persistence/ModelData.swift:60

@MainActor/MainActor.run, DispatchQueue.main, and RunLoop.main are reported as distinct isolation, queue, and event-loop mechanisms. A plain Task is kept separate from Task.detached; neither is labeled as a background thread.

Reference code

AppIntentsTravelTracking/AppIntentsTravelTracking/AppIntentsTravelTracking.swift:36 — representative execution boundary

@main
struct AppIntentsTravelTrackingApp: App {
    // ...
                    try? await EntityDonator.donateLandmarks(modelData: modelData)
    // ...
}

State propagation, frameworks, and dependencies

Evidence limit: an import proves a source-level compilation dependency at the cited line; it does not prove runtime use, architectural adoption, or whether a Swift package is a direct application dependency.

Category Mechanism or module Verified role Evidence
State propagation SwiftUI state property wrapper A SwiftUI property wrapper supplies or observes UI state. AppIntentsTravelTracking/AppIntentsTravelTracking/AppIntentsTravelTracking.swift:17
State propagation @Observable Observation macro publishes source-visible changes. AppIntentsTravelTracking/TravelTrackingShared/Sources/TravelTrackingCore/Models/CollectionStorage.swift:13
Source import TravelTrackingCore The cited file imports this module; runtime use and architectural role are not inferred. AppIntentsTravelTracking/AppIntentsTravelTracking/AppIntentsTravelTracking.swift:10
Source import AppIntents The cited file imports this module; runtime use and architectural role are not inferred. AppIntentsTravelTracking/AppIntentsTravelTracking/AppIntents/TravelTrackingAppShortcuts.swift:8
Source import SwiftUI The cited file imports this module; runtime use and architectural role are not inferred. AppIntentsTravelTracking/AppIntentsTravelTracking/AppIntentsTravelTracking.swift:9
Source import TravelTrackingIntents The cited file imports this module; runtime use and architectural role are not inferred. AppIntentsTravelTracking/AppIntentsTravelTracking/AppIntents/TravelTrackingAppShortcuts.swift:9
Source import Foundation The cited file imports this module; runtime use and architectural role are not inferred. AppIntentsTravelTracking/TravelTrackingShared/Sources/TravelTrackingCore/Models/CollectionStorage.swift:10
Source import WidgetKit The cited file imports this module; runtime use and architectural role are not inferred. AppIntentsTravelTracking/TravelGalleryWidget/NavigateGalleryIntent.swift:9

receive(on:) describes downstream delivery scheduling, while subscribe(on:) describes upstream subscription/request/cancel scheduling. An import Combine alone establishes neither behavior nor a Store, reducer, Redux, or other application architecture.

Class and protocol design

AppIntentsTravelTracking/TravelTrackingShared/Sources/TravelTrackingCore/Models/GalleryItem.swift:12 — representative type boundary

public protocol GalleryItem: Hashable {
    var displayName: String { get }
    var displayImageName: String { get }
    var displayThumbnailName: String { get }
}
Type Responsibility Depends on or conforms to
AppIntentsTravelTrackingApp Application entry and top-level composition App
SharedDataStore Centralized state or persistence access Sendable
ContentView User-interface presentation and input forwarding View
SearchView User-interface presentation and input forwarding View
SearchEngine Owns processing or simulation work Concrete collaborators/imported frameworks
PhotoDetailInspectorView User-interface presentation and input forwarding View
TagsFlowView User-interface presentation and input forwarding View
PhotoDetailView User-interface presentation and input forwarding View
LandmarkTicketPriceView User-interface presentation and input forwarding View
TicketRequestView User-interface presentation and input forwarding View

The source explicitly defines local protocol relationships: LandmarkGalleryItem, TravelPhotoGalleryItem, LandmarkCollectionTravelCollection, PhotoAlbumTravelCollection.

Access control

Symbol Access Verified effect Likely rationale
appShortcuts (AppIntentsTravelTracking/AppIntentsTravelTracking/AppIntents/TravelTrackingAppShortcuts.swift:13) public The symbol is visible to importing modules. Inference: make the declaration available across a module or target boundary.
modelData (AppIntentsTravelTracking/AppIntentsTravelTracking/AppIntentsTravelTracking.swift:17) private Use is restricted to the lexical declaration and same-file extensions allowed by Swift. Inference: keep state mutation or dependency lifetime inside the owning implementation.
navigator (AppIntentsTravelTracking/AppIntentsTravelTracking/AppIntentsTravelTracking.swift:18) private Use is restricted to the lexical declaration and same-file extensions allowed by Swift. Inference: keep state mutation or dependency lifetime inside the owning implementation.
scenePhase (AppIntentsTravelTracking/AppIntentsTravelTracking/AppIntentsTravelTracking.swift:19) private Use is restricted to the lexical declaration and same-file extensions allowed by Swift. Inference: keep state mutation or dependency lifetime inside the owning implementation.

Reference code

AppIntentsTravelTracking/AppIntentsTravelTracking/AppIntents/TravelTrackingAppShortcuts.swift:13 — representative boundary

    public static var appShortcuts: [AppShortcut] {
        // ...
            shortTitle: "Navigate",
            systemImageName: "arrowshape.forward"
        // ...
    }

Swift declarations without a modifier are internal; explicit private, fileprivate, private(set), public, or open entries above are interpreted by language semantics. Objective-C/C samples instead rely on header and implementation boundaries, which are not equivalent to Swift lexical privacy.

Logic ownership and placement

Logic Owning type or file Placement rationale
Application entry and top-level composition AppIntentsTravelTrackingApp The source’s App suffix makes this role explicit.
Owns processing or simulation work SearchEngine The source’s Engine suffix makes this role explicit.
Supplies a capability or framework resource GalleryTimelineProvider The source’s Provider suffix makes this role explicit.
Centralized state or persistence access SharedDataStore The source’s Store suffix makes this role explicit.
User-interface presentation and input forwarding CollectionDetailContainerView, CollectionTileView, CollectionsGridView, ContentView The source’s View suffix makes this role explicit.

Design patterns

Pattern Source evidence Purpose or tradeoff
Protocol-oriented abstraction AppIntentsTravelTracking/TravelTrackingShared/Sources/TravelTrackingCore/Models/GalleryItem.swift:20 A local protocol and concrete conformance create an explicit capability boundary.
Delegate or data-source callbacks AppIntentsTravelTracking/TravelTrackingShared/Sources/TravelTrackingCore/Utilities/LocationFinder.swift:15 Callback protocols invert event delivery back into the sample’s owner.
Central store AppIntentsTravelTracking/TravelTrackingShared/Sources/TravelTrackingCore/Persistence/SharedDataStore.swift:50 A store-named type centralizes feature state or persistence.
Binding-based state propagation AppIntentsTravelTracking/AppIntentsTravelTracking/Views/ContentView.swift:106 A binding exposes controlled read/write access while the upstream owner remains authoritative.
Actor isolation AppIntentsTravelTracking/TravelTrackingShared/Sources/TravelTrackingSnippets/FindTickets/SearchEngine.swift:25 A declared actor creates an explicit isolation boundary; its executor is not described as a background thread.

Main application flow

Reference code

AppIntentsTravelTracking/TravelTrackingShared/Sources/TravelTrackingIntents/Intents/Landmarks/GetCrowdStatusIntent.swift:44perform()

    public func perform() async throws -> some ReturnsValue<Int> & ProvidesDialog {

        guard await modelData.isLandmarkOpen(landmark) else { /* Exit early... */
            return .result(value: 0, dialog: "\(landmark.name) is closed.")
        }

        if systemContext.currentMode.canContinueInForeground {
            do {
                try await continueInForeground(alwaysConfirm: false)
                #if os(iOS)
                // You don't need to add code here to open the app
                // and navigate to the scene that matches the intent.
                // Instead, ContentView` uses `.onAppIntentExecution()` view modifiers
                // for navigation.
                #elseif os(macOS)
                await navigator.navigate(to: landmark)
                #endif
            } catch {
                // Open app denied.
            }
        }

        // Retrieve status and return dialog...

        let status = await modelData.crowdStatus(for: landmark)

        return .result(
            value: status,
            dialog: IntentDialog(crowdStatusDescription(for: status))
        )
    }

Naming conventions

  • Types: App: AppIntentsTravelTrackingApp; Engine: SearchEngine; Provider: GalleryTimelineProvider; Store: SharedDataStore; View: CollectionDetailContainerView, CollectionTileView, CollectionsGridView, ContentView, FeaturedItemView.
  • Protocols: GalleryItem, TravelCollection.
  • Methods: tags, widgetGalleryIndex, setLandmarkFavorite, setPhotoFavorite, setTags, setHasSeededFavorites, setWidgetGalleryIndex, setFeaturedLandmarkID.
  • Files: AppIntentsTravelTracking/TravelTrackingShared/Sources/TravelTrackingCore/Persistence/SharedDataStore.swift, AppIntentsTravelTracking/TravelGalleryWidget/TravelGalleryWidgetBundle.swift, AppIntentsTravelTracking/AppIntentsTravelTracking/Views/ContentView.swift, AppIntentsTravelTracking/TravelTrackingShared/Sources/TravelTrackingIntents/Entities/PhotoEntity.swift, AppIntentsTravelTracking/TravelTrackingShared/Sources/TravelTrackingIntents/Entities/PhotoAlbumEntity.swift, AppIntentsTravelTracking/TravelTrackingShared/Sources/TravelTrackingSnippets/FindTickets/SearchEngine.swift.

Architecture takeaways

  • AppIntentsTravelTracking is the main source-visible entry or composition anchor for this sample.
  • Framework work reaches TravelTrackingCore, AppIntents, SwiftUI, TravelTrackingIntents through a deliberately small high-level chain; the detailed API graph remains inside the cited implementation files.
  • Stored-property evidence identifies lifecycle collaboration; it does not by itself prove exclusive object ownership.
  • Access-control conclusions separate verified language visibility from the likely design rationale.
  • Local protocol relationships provide an explicit substitution boundary.

Source map

Source file Relevant symbols
AppIntentsTravelTracking/AppIntentsTravelTracking/AppIntentsTravelTracking.swift Cited implementation, await suspension point, SwiftUI state property wrapper, TravelTrackingCore, SwiftUI, AppIntentsTravelTrackingApp
AppIntentsTravelTracking/TravelTrackingShared/Sources/TravelTrackingCore/Models/GalleryItem.swift GalleryItem, Cited implementation
AppIntentsTravelTracking/AppIntentsTravelTracking/AppIntents/TravelTrackingAppShortcuts.swift Cited implementation, AppIntents, TravelTrackingIntents
AppIntentsTravelTracking/TravelTrackingShared/Sources/TravelTrackingCore/Utilities/LocationFinder.swift Cited implementation, LocationFinder
AppIntentsTravelTracking/TravelTrackingShared/Sources/TravelTrackingCore/Persistence/SharedDataStore.swift SharedDataStore, DefaultsKey
AppIntentsTravelTracking/AppIntentsTravelTracking/Views/ContentView.swift Cited implementation, Task, ContentView, CollectionsSection, CollectionsSectionPicker, CollectionsTab, SearchView
AppIntentsTravelTracking/TravelTrackingShared/Sources/TravelTrackingSnippets/FindTickets/SearchEngine.swift SearchEngine, SearchStatus
AppIntentsTravelTracking/TravelTrackingShared/Sources/TravelTrackingCore/Models/Landmark.swift Sendable or @Sendable, Landmark
AppIntentsTravelTracking/TravelTrackingShared/Sources/TravelTrackingCore/Models/TravelCollection.swift @MainActor, TravelCollection
AppIntentsTravelTracking/TravelTrackingShared/Sources/TravelTrackingCore/Persistence/ModelData.swift MainActor.run, ModelData, Continent
AppIntentsTravelTracking/TravelTrackingShared/Sources/TravelTrackingCore/Models/CollectionStorage.swift @Observable, Foundation, CollectionStorage
AppIntentsTravelTracking/TravelGalleryWidget/NavigateGalleryIntent.swift WidgetKit, GalleryDirection, NavigateGalleryIntent
AppIntentsTravelTracking/TravelGalleryWidget/TravelGalleryWidgetBundle.swift TravelGalleryWidgetBundle
AppIntentsTravelTracking/TravelTrackingShared/Sources/TravelTrackingIntents/Entities/PhotoEntity.swift PhotoAssetType, PhotoFilterEffectType, PhotoEntity, PhotoEntityQuery
AppIntentsTravelTracking/TravelTrackingShared/Sources/TravelTrackingIntents/Entities/PhotoAlbumEntity.swift PhotoAlbumType, PhotoAlbumEntity, PhotoAlbumEntityQuery
AppIntentsTravelTracking/AppIntentsTravelTracking/Views/Photos/Photo/PhotoDetailInspectorView.swift PhotoDetailInspectorView, TagsFlowView, TagFlowLayout
AppIntentsTravelTracking/TravelTrackingShared/Sources/TravelTrackingIntents/Intents/Landmarks/GetCrowdStatusIntent.swift perform