App Intents and Shortcuts

Modern platform Mid-level Swift 5.9+ iOS 17+ Reviewed By Alok Singh

Fill the blank

Fill the blank to finish the intent.

import AppIntents

struct StartFocusTimer: AppIntent {
    static let title: LocalizedStringResource = "Start Focus Timer"
    @Parameter(title: "Minutes") var minutes: Int

    func perform() async throws -> some IntentResult {
        await TimerStore.shared.start(minutes: minutes)
        return ____
    }
}
Options
Hint 1 of 1

IntentResult has a static factory.

Choose an answer, then open Show answer below to check it.

Show answer

Answer: A .result()

Correct. It returns an IntentResult with no extra value or dialog.

Why not the others?
  • B .success. There is no .success on IntentResult.
  • C nil. perform must return a result.
  • D Void(). Void isn't an IntentResult.

30-second answer

An App Intent is a Swift type describing an action your app can perform, with a title, parameters and a perform() method. The system uses it for Shortcuts, Siri, Spotlight, widgets, controls and the Action button. Add an AppShortcutsProvider with phrases so the action works without any setup by the user, and use AppEntity for your app's objects.

Practise saying it · 45 s. No recording, just a timer

Explain App Intents.

Say your answer out loud, then check which of these points you covered:

  • Typed actions
  • perform()
  • App Shortcuts phrases
  • Reused across the system

Deep dive

Parameters use @Parameter and can ask the user for missing values.

Return dialogs or snippets for Siri responses.

The same intent powers interactive widgets and controls.

Set openAppWhenRun when the action needs the app's UI.

Common mistakes

  • Duplicating logic between intents and the app.
  • Forgetting App Shortcuts phrases, so users must set it up manually.

Senior take & follow-ups

Seniors design intents as the app's public actions and reuse them everywhere.

Follow-up questions

Think of your answer first, then open the hint.

  1. How do you expose your app's data?

    Show hint

    AppEntity with an EntityQuery.

  2. Where else do intents appear?

    Show hint

    Spotlight, widgets, controls, the Action button and Apple Intelligence features.

Suggest a fix if something here is wrong or out of date.