skip to Main Content

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


2

Answers


  1. Chosen as BEST ANSWER

    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…


  2. // 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
    

    In this scenario, when you opening a view, you don’t need parameter at all. I might be wrong, but it is possible you misunderstood the API. Parameters are things which visible in Shortcuts, and your code looks like something which should be hidden.

    Also, your AppIntent implementation missing perform() function.

    I found videos from Michael Summer and Roman Efimov to be useful and it is packed with details you can’t just guess.

    Update
    I am just rewatching these videos and something caught my attention which might be relevant to your Spotlight issue.

    It’s important to note that if your intent does trigger an app launch, it won’t be shown in Spotlight.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search