I want to be able to dynamically update the phrase dictionary in an AppShortcut. However, whenever I abstract the phrases, the shortcut fails to display. That is, I am trying to do:
static var phrases: [AppShortcutPhrase<MyIntent>] = ["\(.applicationName) hello world"]
AppShortcut(
intent: MyIntent(),
phrases: phrases,
shortTitle: "hello world",
systemImageName: ""
)
However, the following works:
AppShortcut(
intent: MyIntent(),
phrases: "\(.applicationName) hello world",
shortTitle: "hello world",
systemImageName: ""
)
So, what gives?
The phrases array for an App Shortcut is statically extracted during the build of your app. This process means that the content cannot be altered dynamically. The system automatically provides you with flexible phrase matching, so phrases from your customer that are similar to the ones you set in your App Shortcut code will still be matched to your App Shortcut by the system.
— Ed Ford, DTS Engineer