Back to Swift Reference
🧠 Apple IntelligenceIntermediateiOS 16+

App Intents for Siri & Shortcuts

Expose app actions to Siri, Spotlight, Shortcuts and Apple Intelligence with a small Swift type.

An AppIntent describes one action: its title, parameters and a perform() method. The system can then run it from Siri, Spotlight or the Action button.

AppShortcutsProvider makes intents available immediately after install, with natural phrases.

app-intents.swift
1import AppIntents
2
3struct LogHabitIntent: AppIntent {
4    static let title: LocalizedStringResource = "Log Habit"
5
6    @Parameter(title: "Habit name")
7    var name: String
8
9    func perform() async throws -> some IntentResult & ProvidesDialog {
10        try await HabitStore.shared.log(name)
11        return .result(dialog: "Logged \(name). Keep the streak going!")
12    }
13}
14
15struct HabitShortcuts: AppShortcutsProvider {
16    static var appShortcuts: [AppShortcut] {
17        AppShortcut(
18            intent: LogHabitIntent(),
19            phrases: ["Log a habit in \(.applicationName)"],
20            shortTitle: "Log Habit",
21            systemImageName: "checkmark.circle"
22        )
23    }
24}

Common pitfalls

  • Every phrase must include \(.applicationName) or the shortcut will not register.

Still unclear? Ask BeeAI about App Intents for Siri & Shortcuts.

Get a tailored explanation, or paste your own code for a Swift 6 review. Free members get daily questions — Pro is unlimited.

Ask BeeAI

Become a Founding Pro member: unlimited BeeAI, upcoming Swift paths and every new reference entry first.

See Pro Plans