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.

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.

Class and protocol design

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

protocol LocalizableShortcutString {
    // ...
}
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/OrderDetailViewController.swift OrderDetailViewController, Purpose, Section, CellType, Item
Shared/Data/DataManager.swift UserDefaultsStorageDescriptor, DataManager
SoupChef/App Intent/OrderSoup.swift OrderSoup, CLPlacemarkOptionsProvider, OrderSoupError, OrderPreviewView, OrderConfirmedView
SoupChef/UI/AppDelegate.swift AppDelegate
SoupChef/UI/OrderHistoryViewController.swift OrderHistoryViewController, SegueIdentifiers, Section
SoupChef/UI/SoupMenuViewController.swift SoupMenuViewController, SegueIdentifiers, Section
SoupChef/UI/ConfigureMenuTableViewController.swift ConfigureMenuTableViewController, SectionType
SoupChefIntentsUI/InvoiceViewController.swift InvoiceViewController, InvoiceView
SoupChefIntentsUI/OrderConfirmedViewController.swift OrderConfirmedViewController, OrderConfirmedView
SoupChef/App Intent/SoupAppEntity.swift SoupAppEntity, SoupAppEntityQuery