App Intent not Discoverable by Siri

I'm implementing the iOS 16 AppIntents framework and it works fine except when I try to trigger it with Siri, which just pulls up results from the web. Here's a very simple version I made on an empty project.

import Foundation

import AppIntents



@available(iOS 16.0, *)

struct ShowMeBooks: AppIntent {

    static var openAppWhenRun: Bool = false

    static var title: LocalizedStringResource = "Show me my books"

    

    func perform() async throws -> some IntentPerformResult {

        let x = 1 + 1

        return .finished(dialog: "Here are your books")

    }

}



@available(iOS 16.0, *)

struct SouthwestShortcuts: AppShortcutsProvider {

    static var appShortcuts: [AppShortcut] {

        AppShortcut(

            intent: ShowMeBooks(),

            phrases: ["Show me my books on \(.applicationName)"]

        )

    }

}
  • Forgot to add: I expected the shortcut to be run after calling Siri on the simulator and saying "Show me my books on MyNewTestApp".

Add a Comment

Replies

just say "Show me my books". don't need your app name.

Also it seems you don't need the AppShortcutsProvider. I was able to get it working with just the AppIntent struct

struct ShowMeMyBooks: AppIntent {
    static var title: LocalizedStringResource = "Show me my books"

    @MainActor
    func perform() async throws -> some IntentResult {
        return .result(dialog: "These are your books")
    }
    static var openAppWhenRun: Bool = false
}

note: it seems the sample code in the WWDC session is wrong. its right in the video but not in the attached code.

I updated to Xcode 14.0 Beta 3 and my code didn't compile anymore so I had to change .finished to .result and add @MainActor like yours. I tried your code and Siri worked once...I couldn't recreate it even after deleting all contents and settings. I guess it's just Xcode being funky so I'll give it some time. Thank you.