iosswiftsirishortcutsios17appintents

Parameterized App Shortcut isn’t showing up correctly in Spotlight (iOS 17)


I’m working on supporting iOS 17’s new Shortcuts features. I have a multiple App Shortcuts including one that launches the app in a selected tab. The tab selection is done via a custom AppView enum that conforms to the AppEnum protocol.

The problem is that for some reason the open in view XYZ action doesn’t show correctly in Spotlight. As you can see in the screenshot below it doesn’t have any icon or title. Also in the Shortcuts app itself only the Action resulting from the first phrase shows up. The AppView based phrase actions only show up as old App Shortcuts below.

Any idea how to fix that issue?

App Shortcuts Definition

struct AppShortcuts: AppShortcutsProvider {
    static var shortcutTileColor: ShortcutTileColor = .grape
    
    static var appShortcuts: [AppShortcut] {
        AppShortcut(
            intent: OpenAppIntent(),
            phrases: [
                "Open \(.applicationName)",
                "Open \(\.$view) in \(.applicationName)"
            ],
            shortTitle: "Open",
            systemImageName: "arrow.up.forward.app"
        )
        // Other App Shortcuts …
    }
}

AppView App Enum

extension AppView: AppEnum {
    static var typeDisplayRepresentation = TypeDisplayRepresentation(name: "View")
    
    static var caseDisplayRepresentations: [Self : DisplayRepresentation] = [
        .insights: DisplayRepresentation(title: LocalizedStringResource("Insights", table: "Shortcuts", comment: "App View Label"),
                                         image: .init(systemName: "chart.xyaxis.line")),
        .events: DisplayRepresentation(title: LocalizedStringResource("Events", table: "Shortcuts", comment: "App View Label"),
                                       image: .init(systemName: "calendar")),
        .meters: DisplayRepresentation(title: LocalizedStringResource("Meters", table: "Shortcuts", comment: "App View Label"),
                                       image: .init(systemName: "barometer"))
    ]
}

Shortcut Definition

struct OpenAppIntent: AppIntent {
    
    // Launches app when action is triggered
    static let openAppWhenRun: Bool = true
    
    // App View Parameter
    @Parameter(title: "View",
               description: "The view inside the app.",
               default: .insights,
               requestValueDialog: IntentDialog("Where would you like to navigate to?"))
    var view: AppView
    
    // Title, Description, Parameter Summary & perform()
}

Screenshots


Solution

  • After filing a Feedback (FB13157399) to Apple, this issue got fixed in iOS 17.1 Beta 2.

    Now I only get a WFBackgroundShortcutRunnerErrorDomain error 1 when performing the actual shortcut, but that might also be related to the fact that it is still beta…