On iOS, when trying to run an AppIntent that's added to the Shortcuts app and my app is in a killed state, I get the following error: Error Domain=LNActionForAutoShortcutPhraseFetchError Code=1 "Couldn't find AppshortcutsProvider." UserInfo={NSLocalizedDescription=Couldn't find AppShortcutsProvider. It seems from the error that the AppShortcutsProvider cannot be found, however when I run the shortcut when the app is not in a killed state, it runs perfectly fine.
Relevant code below:
struct ExampleIntent: AppIntent, WidgetConfigurationIntent {
static let title: LocalizedStringResource = "Title"
static let description: IntentDescription = IntentDescription("Description")
func perform() async throws -> some IntentResult & ProvidesDialog {
// Performing relevant logic
return .result(
dialog: IntentDialog(stringLiteral: "Result message")
)
}
}
AppShortcutsProvider (in the main app, not in an extension):
@available(iOS 17.0, *)
struct ExampleShortcutsProvider: AppShortcutsProvider {
static var appShortcuts: [AppShortcut] {
AppShortcut(
intent: ExampleIntent(),
phrases: ["Perform the example intent"],
shortTitle: "Example Shortcut",
systemImageName: "info.circle.fill"
)
}
}
If I add static let openAppWhenRun: Bool = true to the ExampleIntent, it runs perfectly fine, also when the app is in a killed state. I could not find any documentation on this - does anyone know why this is the behavior?