I am trying to create a shortcut following "Implement App Shortcuts With App Intents" talk from WWDC2022.
The below is my MWE. In a standalone app, this can be extended and behave like the video. Adding this code to my main app, makes the shortcut show up within the Shortcuts app, but if I click on it, it pops up an alert saying
Error Domain=LNActionForAutoShortcutPhraseFetchError Code=1 "Couldn't find AppShortcutsProvider" UserInfo={NSLocalizedDescription=Couldn't find AppShortcutsProvider}
My main app has several targets, so I suppose I need to establish which one is the shortcuts provider, but I cannot find any reference to how to do this in the documents.
Via Siri, the shortcut command is not recognised at all.
import AppIntents
import SwiftUI
struct DoSomething: AppIntent {
static var title: LocalizedStringResource = "Do something"
func perform() async throws -> some IntentResult {
return .result()
}
static var openAppWhenRun: Bool = false
}
struct MyShortcuts: AppShortcutsProvider {
@AppShortcutsBuilder
static var appShortcuts: [AppShortcut] {
AppShortcut(
intent: DoSomething(),
phrases: ["Do Something in \(.applicationName)"],
systemImageName: "books.vertical.fill"
)
}
}