App Intents: Shortcuts and Siri for your SwiftUI app
App Intents put your app into Shortcuts, Siri, Spotlight and widgets. Here is how to build your first action in SwiftUI, step by step, with code.
App Intents are Apple's way to make your app's actions available outside the app: in the Shortcuts app, through Siri, in Spotlight, on the Action button and in interactive widgets. You describe an action once in Swift, and the system offers it wherever it fits.
The big win: people don't have to open your app to do a common task. Add a note, start a timer, check today's status. These small paths often decide whether an app stays part of someone's day.
Your first action: an AppIntent
An action is a struct that conforms to the AppIntent protocol. It needs a title and a perform function that does the actual work:
import AppIntents
struct AddNote: AppIntent {
static let title: LocalizedStringResource = "Add Note"
@Parameter(title: "Text")
var text: String
func perform() async throws -> some IntentResult & ProvidesDialog {
try await NoteStore.shared.add(text)
return .result(dialog: "Note saved.")
}
}With @Parameter, the system asks for the text when it's missing. In Shortcuts it becomes a field, with Siri a follow-up question. Siri reads the dialog aloud or shows it as a confirmation.
No setup needed: App Shortcuts for Siri and Spotlight
To make an action available right after installation, without anyone building a shortcut, use an AppShortcutsProvider. In it you define the phrases Siri listens for. Every phrase has to contain your app's name:
struct MyShortcuts: AppShortcutsProvider {
static var appShortcuts: [AppShortcut] {
AppShortcut(
intent: AddNote(),
phrases: ["New note in \(.applicationName)"],
shortTitle: "Add Note",
systemImageName: "square.and.pencil"
)
}
}These App Shortcuts show up automatically in the Shortcuts app and in Spotlight, and people can assign them to the Action button. Keep the phrases short and natural, the way people actually talk.
Your own data with AppEntity
If an action should work with things from your app, such as a specific list or project, describe those things as an AppEntity. A matching EntityQuery gives the system the options to choose from. That way someone can pick “List: Groceries” in Shortcuts without you building any extra interface.
A good display matters: give every entity a readable name and ideally a symbol. That is what people see in Siri, Spotlight and Shortcuts.
The same action in widgets and Control Center
App Intents also power interactive widgets. A Button(intent:) inside a widget runs your action directly, without opening the app. How widgets work in general is covered in Widgets with SwiftUI and WidgetKit. Since iOS 18, actions can also become controls in Control Center and on the Lock Screen.
If you want to go further with Apple Intelligence, the post about Foundation Models is the next step.
Tips so people actually find your actions
- Start with two or three actions people use often instead of offering everything.
- Write titles as verbs: “Add Note” rather than “Note”.
- Return a short, clear confirmation after every action.
- Test the phrases out loud with Siri, in every language your app supports.
- Surface the actions inside your app, for example with a ShortcutsLink, so people learn about them.
With very little code your app becomes part of the system. That saves people time and brings them back to your app more often.