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

Integrating your photo app with Apple Intelligence

At a glance

Item Summary
Purpose Adopt photo schemas so people can edit and manage photos with Siri.
App architecture A Swift sample with the source-visible chain PhotosDomainExampleContentViewImageManagerExampleAppShortcutsProviderAppIntents APIs.
Main patterns Actor isolation
Project style 29 scanned source file(s) across Swift, organized around ranked entry, type, and file boundaries.
Execution model Source-visible boundaries: @MainActor, async declaration or closure, actor, Task, Sendable or @Sendable; none alone proves a background thread.
State/event model Source-visible mechanisms: SwiftUI state property wrapper, @Observable.
Key frameworks/packages SwiftUI, AppIntents, Foundation, Photos, GeoToolbox; these are source dependencies, not architecture labels.

Project structure

Source bundle/
└── PhotosDomainExample/
    ├── PhotosDomainExample.swift
    ├── AppIntents/
    │   ├── Album/
    │   │   └── AlbumIntents.swift
    │   ├── ShortcutsProvider.swift
    │   └── Asset/
    │       └── AssetIntents.swift
    ├── Managers/
    │   ├── ImageManager.swift
    │   ├── NavigationManager.swift
    │   └── LocationManager.swift
    ├── Views/
    │   ├── Album/
    │   │   ├── AlbumNameView.swift
    │   │   └── AlbumDetailView.swift
    │   ├── Asset/
    │   │   └── AssetDetailView.swift
    │   └── FavoriteView.swift
    └── ContentView.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 5 project/configuration file(s) and 45 source declaration(s).

Overall architecture

Reference code

PhotosDomainExample/PhotosDomainExample.swift:11 — architecture anchor

@main
struct PhotosDomainExample: App {

    // MARK: Life cycle

    let library: MediaLibrary
    let navigationManager: NavigationManager

    init() {
        let navigationManager = NavigationManager()
        let library = MediaLibrary()
        library.load()
        AppDependencyManager.shared.add(dependency: library)
        AppDependencyManager.shared.add(dependency: navigationManager)
        self.library = library
        self.navigationManager = navigationManager
    }

    var body: some Scene {
        WindowGroup {
            ContentView()
        }
        .environment(library)
        .environment(navigationManager)
    }
}

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

PhotosDomainExample/AppIntents/Album/AlbumIntents.swift:13 — stored dependency or nearest verified ownership anchor

@AppIntent(schema: .photos.createAlbum)
struct CreateAlbumIntent: AppIntent {
    var name: String
    // ...
}
Owner Object or state Relationship Mutation authority
CreateAlbumIntent String (name) owns value state App/module collaborators
CreateAlbumIntent MediaLibrary (library) stores or receives App/module collaborators
OpenAlbumIntent AlbumEntity (target) stores or receives App/module collaborators
OpenAlbumIntent MediaLibrary (library) stores or receives App/module collaborators

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
Main isolation @MainActor The cited annotation marks its attached declaration or closure as main-actor isolated. PhotosDomainExample/AppIntents/Album/AlbumEntity.swift:40
Suspension boundary async declaration or closure The source declares or crosses an asynchronous boundary; it does not by itself establish background execution. PhotosDomainExample/AppIntents/Album/AlbumEntity.swift:41
Actor isolation actor The cited type is actor-isolated; this does not select a background thread. PhotosDomainExample/Managers/ImageManager.swift:11
Task creation Task The source creates an unstructured task; surrounding context determines inherited actor isolation. PhotosDomainExample/Managers/LocationManager.swift:27
Transfer contract Sendable or @Sendable The source declares a sendability boundary; this alone does not synchronize mutable state. PhotosDomainExample/Model/Album.swift:36

@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

PhotosDomainExample/AppIntents/Album/AlbumEntity.swift:40 — representative execution boundary

        @MainActor
        func entities(for identifiers: [AlbumEntity.ID]) async throws -> [AlbumEntity] {
            library.albums(for: identifiers).map(\.entity)
        }

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. PhotosDomainExample/ContentView.swift:14
State propagation @Observable Observation macro publishes source-visible changes. PhotosDomainExample/Managers/MediaLibrary.swift:12
Source import SwiftUI The cited file imports this module; runtime use and architectural role are not inferred. PhotosDomainExample/AppIntents/Asset/AssetIntents.swift:10
Source import AppIntents The cited file imports this module; runtime use and architectural role are not inferred. PhotosDomainExample/AppIntents/Album/AlbumEntity.swift:8
Source import Foundation The cited file imports this module; runtime use and architectural role are not inferred. PhotosDomainExample/AppIntents/Album/AlbumIntents.swift:9
Source import Photos The cited file imports this module; runtime use and architectural role are not inferred. PhotosDomainExample/Managers/ImageManager.swift:8
Source import GeoToolbox The cited file imports this module; runtime use and architectural role are not inferred. PhotosDomainExample/AppIntents/Asset/AssetEntity.swift:10
Source import CoreSpotlight The cited file imports this module; runtime use and architectural role are not inferred. PhotosDomainExample/Managers/MediaLibrary.swift:8

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

PhotosDomainExample/AppIntents/ShortcutsProvider.swift:10 — representative type boundary

struct ExampleAppShortcutsProvider: AppShortcutsProvider {
    // ...
            shortTitle: "Create",
            systemImageName: "photo.badge.plus"
    // ...
}
Type Responsibility Depends on or conforms to
ExampleAppShortcutsProvider Supplies a capability or framework resource AppShortcutsProvider
ImageManager Long-lived feature or framework coordination Concrete collaborators/imported frameworks
NavigationManager Long-lived feature or framework coordination Concrete collaborators/imported frameworks
AlbumNameView User-interface presentation and input forwarding View
AssetDetailView User-interface presentation and input forwarding View
MediaView User-interface presentation and input forwarding View
ContentView User-interface presentation and input forwarding View
LocationManager Long-lived feature or framework coordination Concrete collaborators/imported frameworks
AlbumDetailView User-interface presentation and input forwarding View
FavoriteView User-interface presentation and input forwarding View

No local protocol conformance is claimed as protocol-oriented design; external framework conformances are listed only as dependencies.

Access control

Symbol Access Verified effect Likely rationale
library (PhotosDomainExample/ContentView.swift:14) 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.
navigation (PhotosDomainExample/ContentView.swift:15) 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.
imageManager (PhotosDomainExample/Managers/ImageManager.swift:23) 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.
imageContentMode (PhotosDomainExample/Managers/ImageManager.swift:25) 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

PhotosDomainExample/ContentView.swift:14 — representative boundary

struct ContentView: View {
    // ...
    @Environment(MediaLibrary.self) private var library
    // ...
}

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
Long-lived feature or framework coordination ImageManager, LocationManager, NavigationManager The source’s Manager suffix makes this role explicit.
Supplies a capability or framework resource ExampleAppShortcutsProvider The source’s Provider suffix makes this role explicit.
User-interface presentation and input forwarding AlbumDetailView, AlbumNameView, AssetDetailView, AssetView The source’s View suffix makes this role explicit.

Design patterns

Pattern Source evidence Purpose or tradeoff
Actor isolation PhotosDomainExample/Managers/ImageManager.swift:11 A declared actor creates an explicit isolation boundary; its executor is not described as a background thread.

Naming conventions

  • Types: Manager: ImageManager, LocationManager, NavigationManager; Provider: ExampleAppShortcutsProvider; View: AlbumDetailView, AlbumNameView, AssetDetailView, AssetView, ContentView.
  • Protocols: no local protocol declaration in the scanned source.
  • Methods: perform, startCaching, stopCaching, requestImage, openAsset, openAlbum, openSearch, saveAction.
  • Files: PhotosDomainExample/PhotosDomainExample.swift, PhotosDomainExample/Managers/ImageManager.swift, PhotosDomainExample/Managers/NavigationManager.swift, PhotosDomainExample/Views/Album/AlbumNameView.swift, PhotosDomainExample/Views/Asset/AssetDetailView.swift, PhotosDomainExample/ContentView.swift.

Architecture takeaways

  • PhotosDomainExample is the main source-visible entry or composition anchor for this sample.
  • Framework work reaches SwiftUI, AppIntents, Photos, GeoToolbox 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.
  • The source does not justify labeling the design protocol-oriented.

Source map

Source file Relevant symbols
PhotosDomainExample/PhotosDomainExample.swift Cited implementation, PhotosDomainExample
PhotosDomainExample/AppIntents/Album/AlbumIntents.swift Cited implementation, Foundation, CreateAlbumIntent, OpenAlbumIntent, UpdateAlbumIntent, DeleteAlbumIntent, AddAssetsToAlbumIntent, RemoveAssetsFromAlbumIntent
PhotosDomainExample/AppIntents/ShortcutsProvider.swift ExampleAppShortcutsProvider
PhotosDomainExample/ContentView.swift Cited implementation, SwiftUI state property wrapper, ContentView
PhotosDomainExample/Managers/ImageManager.swift Cited implementation, ImageManager, actor, Photos, ImageError
PhotosDomainExample/AppIntents/Album/AlbumEntity.swift @MainActor, async declaration or closure, AppIntents, AlbumEntity, AlbumQuery
PhotosDomainExample/Managers/LocationManager.swift Task, LocationManager
PhotosDomainExample/Model/Album.swift Sendable or @Sendable, Album
PhotosDomainExample/Managers/MediaLibrary.swift @Observable, CoreSpotlight, MediaLibrary, Error
PhotosDomainExample/AppIntents/Asset/AssetIntents.swift SwiftUI, IntentError, CreateAssetsIntent, OpenAssetIntent, UpdateAssetIntent, DeleteAssetsIntent, SearchAssetsIntent
PhotosDomainExample/AppIntents/Asset/AssetEntity.swift GeoToolbox, AssetEntity, AssetQuery
PhotosDomainExample/Managers/NavigationManager.swift NavigationManager, Selection
PhotosDomainExample/Views/Album/AlbumNameView.swift AlbumNameView, Focus
PhotosDomainExample/Views/Asset/AssetDetailView.swift AssetDetailView, MediaView
PhotosDomainExample/Views/Album/AlbumDetailView.swift AlbumDetailView
PhotosDomainExample/Views/FavoriteView.swift FavoriteView