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

Soup Chef with App Intents: Migrating custom intents

At a glance

Item Summary
Purpose Integrating App Intents to provide your appʼs actions to Siri and Shortcuts.
App architecture A C/Objective-C header, Swift sample with the source-visible chain AppDelegateConfigureMenuTableViewControllerDataManagerCLPlacemarkOptionsProviderIntents / AppIntents APIs.
Main patterns View-controller organization, Protocol-oriented abstraction, Delegate or data-source callbacks
Project style 32 scanned source file(s) across C/Objective-C header, Swift, organized around ranked entry, type, and file boundaries.
Execution model Source-visible boundaries: DispatchQueue(label:), async declaration or closure; none alone proves a background thread.
State/event model Source-visible mechanisms: NotificationCenter.
Key frameworks/packages Foundation, SoupKit, UIKit, Intents, os; these are source dependencies, not architecture labels.

Project structure

Source bundle/
├── SoupChef/
│   ├── UI/
│   │   ├── OrderDetailViewController.swift
│   │   ├── AppDelegate.swift
│   │   ├── OrderHistoryViewController.swift
│   │   ├── SoupMenuViewController.swift
│   │   └── ConfigureMenuTableViewController.swift
│   └── App Intent/
│       ├── OrderSoup.swift
│       ├── SoupAppEntity.swift
│       └── ToppingAppEntity.swift
├── Shared/
│   └── Data/
│       ├── DataManager.swift
│       └── SoupMenuManager.swift
└── SoupChefIntentsUI/
    ├── InvoiceViewController.swift
    └── OrderConfirmedViewController.swift

Structure observations

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

Overall architecture

Reference code

SoupChef/UI/AppDelegate.swift:13 — architecture anchor

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(_ application: UIApplication, handlerFor intent: INIntent) -> Any? {
        return OrderSoupIntentHandler()
    }
}

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 Intents.

Ownership and state

Ownership evidence

Shared/Data/DataManager.swift:14 — stored dependency or nearest verified ownership anchor

struct UserDefaultsStorageDescriptor {
    /// A `String` value used as the key name when reading and writing to `UserDefaults`.
    let key: String

    /// A key path to a property on `UserDefaults` for observing changes.
    let keyPath: KeyPath<UserDefaults, Data?>
}
Owner Object or state Relationship Mutation authority
UserDefaultsStorageDescriptor String (key) owns value state Initialized by the owner; the binding is immutable
UserDefaultsStorageDescriptor KeyPath (keyPath) stores or receives Initialized by the owner; the binding is immutable
UserDefaultsStorageDescriptor NSNotification (dataChangedNotificationKey) stores or receives Initialized by the owner; the binding is immutable
DataManager DispatchQueue (userDefaultsAccessQueue) creates and retains 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
Queue scheduling DispatchQueue(label:) The source constructs a dispatch queue; its label alone does not prove a thread. Shared/Data/DataManager.swift:30
Suspension boundary async declaration or closure The source declares or crosses an asynchronous boundary; it does not by itself establish background execution. SoupChef/App Intent/OrderSoup.swift:43

@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

Shared/Data/DataManager.swift:30 — representative execution boundary

public class DataManager<ManagedDataType: Codable> {
    // ...
    private let userDefaultsAccessQueue = DispatchQueue(label: "User Defaults Access Queue")
    // ...
}

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 NotificationCenter NotificationCenter distributes named process-local events. Shared/Data/DataManager.swift:77
Source import Foundation The cited file imports this module; runtime use and architectural role are not inferred. Shared/Data/DataManager.swift:8
Source import SoupKit The cited file imports this module; runtime use and architectural role are not inferred. SoupChef/App Intent/OrderSoup.swift:13
Source import UIKit The cited file imports this module; runtime use and architectural role are not inferred. Shared/OrderSoupIntentHandler.swift:8
Source import Intents The cited file imports this module; runtime use and architectural role are not inferred. Shared/Data/Order.swift:11
Source import os The cited file imports this module; runtime use and architectural role are not inferred. Shared/Data/DataManager.swift:9
Source import AppIntents The cited file imports this module; runtime use and architectural role are not inferred. SoupChef/App Intent/OrderDetailsAppEntity.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

Shared/Support/Localizable.swift:11 — representative type boundary

protocol LocalizableShortcutString {
    // ...
    func localizedName(useDeferredIntentLocalization: Bool) -> String
}
Type Responsibility Depends on or conforms to
AppDelegate Receives callback-driven events UIResponder, UIApplicationDelegate
OrderDetailViewController View lifecycle, callbacks, and feature coordination UIViewController
DataManager Long-lived feature or framework coordination Concrete collaborators/imported frameworks
CLPlacemarkOptionsProvider Supplies a capability or framework resource DynamicOptionsProvider
OrderPreviewView User-interface presentation and input forwarding View
OrderConfirmedView User-interface presentation and input forwarding View
OrderHistoryViewController View lifecycle, callbacks, and feature coordination UIViewController
SoupMenuViewController View lifecycle, callbacks, and feature coordination UIViewController
ConfigureMenuTableViewController View lifecycle, callbacks, and feature coordination UITableViewController
InvoiceViewController View lifecycle, callbacks, and feature coordination UIViewController

The source explicitly defines local protocol relationships: MenuItemToppingLocalizableShortcutString, MenuItemLocalizableShortcutString, MenuItemLocalizableCurrency, OrderLocalizableCurrency.

Access control

Symbol Access Verified effect Likely rationale
dataChangedNotificationKey (Shared/Data/DataManager.swift:21) public The symbol is visible to importing modules. Inference: make the declaration available across a module or target boundary.
userDefaultsAccessQueue (Shared/Data/DataManager.swift:30) 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.
storageDescriptor (Shared/Data/DataManager.swift:33) 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.
ignoreLocalUserDefaultsChanges (Shared/Data/DataManager.swift:36) 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

Shared/Data/DataManager.swift:21 — representative boundary

public let dataChangedNotificationKey = NSNotification.Name(rawValue: "DataChangedNotification")

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
View lifecycle, callbacks, and feature coordination ConfigureMenuTableViewController, IntentViewController, InvoiceViewController, OrderConfirmedViewController The source’s Controller suffix makes this role explicit.
Receives callback-driven events AppDelegate, SceneDelegate The source’s Delegate suffix makes this role explicit.
Handles callbacks or feature events IntentHandler, OrderSoupIntentHandler The source’s Handler suffix makes this role explicit.
Long-lived feature or framework coordination DataManager, SoupMenuManager, SoupOrderDataManager The source’s Manager suffix makes this role explicit.
Supplies a capability or framework resource CLPlacemarkOptionsProvider, SoupChefAppShortcutsProvider The source’s Provider suffix makes this role explicit.
User-interface presentation and input forwarding AddToSiriCollectionViewCellContentView, InvoiceView, OrderConfirmedView, OrderPreviewView The source’s View suffix makes this role explicit.

Design patterns

Pattern Source evidence Purpose or tradeoff
View-controller organization SoupChef/UI/ConfigureMenuTableViewController.swift:11 A controller is the verified coordination boundary; this is MVC-style only where a separate model is present.
Protocol-oriented abstraction Shared/Data/Order.swift:15 A local protocol and concrete conformance create an explicit capability boundary.
Delegate or data-source callbacks SoupChef/UI/AppDelegate.swift:14 Callback protocols invert event delivery back into the sample’s owner.

Naming conventions

  • Types: Controller: ConfigureMenuTableViewController, IntentViewController, InvoiceViewController, OrderConfirmedViewController, OrderDetailViewController; Delegate: AppDelegate, SceneDelegate; Handler: IntentHandler, OrderSoupIntentHandler; Manager: DataManager, SoupMenuManager, SoupOrderDataManager; Provider: CLPlacemarkOptionsProvider, SoupChefAppShortcutsProvider; View: AddToSiriCollectionViewCellContentView, InvoiceView, OrderConfirmedView, OrderPreviewView.
  • Protocols: LocalizableShortcutString, LocalizableCurrency.
  • Methods: awakeFromNib, present, addVoiceShortcutViewController, addVoiceShortcutViewControllerDidCancel, editVoiceShortcutViewController, editVoiceShortcutViewControllerDidCancel, configureCollectionView, createCollectionViewLayout.
  • Files: SoupChef/UI/OrderDetailViewController.swift, Shared/Data/DataManager.swift, SoupChef/App Intent/OrderSoup.swift, SoupChef/UI/AppDelegate.swift, SoupChef/UI/OrderHistoryViewController.swift, SoupChef/UI/SoupMenuViewController.swift.

Architecture takeaways

  • AppDelegate is the main source-visible entry or composition anchor for this sample.
  • Framework work reaches SoupKit, UIKit, Intents, AppIntents 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
SoupChef/UI/AppDelegate.swift Cited implementation, AppDelegate
Shared/Data/DataManager.swift Cited implementation, DispatchQueue(label:), NotificationCenter, Foundation, os, UserDefaultsStorageDescriptor, DataManager
Shared/Support/Localizable.swift LocalizableShortcutString, LocalizableCurrency
SoupChef/UI/ConfigureMenuTableViewController.swift ConfigureMenuTableViewController, SectionType
Shared/Data/Order.swift Cited implementation, Intents, Order, MenuItemTopping, Location
SoupChef/App Intent/OrderSoup.swift async declaration or closure, SoupKit, OrderSoup, CLPlacemarkOptionsProvider, OrderSoupError, OrderPreviewView, OrderConfirmedView
Shared/OrderSoupIntentHandler.swift UIKit, OrderSoupIntentHandler
SoupChef/App Intent/OrderDetailsAppEntity.swift AppIntents, OrderDetailsAppEntity
SoupChef/UI/OrderDetailViewController.swift OrderDetailViewController, Purpose, Section, CellType, Item
SoupChef/UI/OrderHistoryViewController.swift OrderHistoryViewController, SegueIdentifiers, Section
SoupChef/UI/SoupMenuViewController.swift SoupMenuViewController, SegueIdentifiers, Section
SoupChefIntentsUI/InvoiceViewController.swift InvoiceViewController, InvoiceView
SoupChefIntentsUI/OrderConfirmedViewController.swift OrderConfirmedViewController, OrderConfirmedView
SoupChef/App Intent/SoupAppEntity.swift SoupAppEntity, SoupAppEntityQuery
SoupChef/App Intent/ToppingAppEntity.swift ToppingAppEntity, ToppingAppEntityQuery
Shared/Data/SoupMenuManager.swift SoupMenuManager