2

I've been trying to setup AppIntents and respective AppShortcuts on my WatchOS target, but they don't show up in the Watch's Shortcuts app.

Using the same setup, it works just fine on the iOS companion. Documentation says AppIntents works with WatchOS, so surely I must have overlooked something? Unfortunately I couldn't find anything relating to the topic online...

EDIT: Running the same build on hardware (iPhone SE: iOS 16.4 + Watch SE: WatchOS 9.4), the shortcuts don't even show up in iOS, while they do in the simulator?!

Now, I could implement the functionality on the companion app and relay the resulting state, but I'd prefer to do it on Watch (trying to avoid some unnecessary extra work). So, any help would be much appreciated. Thanks!

szagun
  • 123
  • 8

2 Answers2

5

Anyone, having problems with App Intents not appearing in your Shortcuts app, have a look at the build log. Search for "intents metadata" and expand the transcript.

It helped in my particular case, initializing a TypeDisplayRepresentable in the "wrong" way. Quite a funny error to waste almost 2 days on:

// this works
static var typeDisplayRepresentation = TypeDisplayRepresentation(name: "Prüfung")
// this does not
static var typeDisplayRepresentation : TypeDisplayRepresentation = .init(name: "Prüfung")

Shortcuts I put on Watch still don't show in the shortcuts app, but I guess they probably aren't supposed to? Who really knows.

szagun
  • 123
  • 8
  • Does it work for you to trigger the shortcut on your watch using Siri? And is that code then executed on the watch or on your iPhone? – Sn0wfreeze Apr 18 '23 at 13:10
  • 1
    @Sn0wfreeze I can show my iOS intents on the Watch side, although nothing seems to get executed, when I press it in Shortcuts app (on neither side. Activating via voice command does not work at all. Compiling a seperate intent with my Watch target still does nothing (with or without `AppShortcutsProvider`), even though the metadata extraction shows no errors. I've got a hunch and will update my answer if it leads to any results. I just wish Apple would write better documentation and not release buggy tools... – szagun Apr 19 '23 at 15:39
  • i have the same issue but the build log shows nothing, no error no warnning, the source of issue is still the TypeDisplayRepresentation. I use `static var typeDisplayRepresentation: TypeDisplayRepresentation = TypeDisplayRepresentation(stringLiteral: "Project")`, which is "incorrect", lol – Yinzo Jul 11 '23 at 07:45
0

Today I managed to get Siri to actually show up the App Shortcuts. When first saying the trigger phrase Siri would ask if the shortcuts should be activated and it would show all available shortcut phrases. BUT when I then say the shortcut, Siri does something, but nothing is done. I made an empty shortcut just returning a dialog with Test succeeded. Here's the entire code for the watchOS App Intents extensions.

@main
struct SiriAppIntentsExtensionTestExtension: AppIntentsExtension {
}
 
struct SiriAppIntentsExtensionTest: AppIntent {
    static var title: LocalizedStringResource = "Test Intent"
    
    func perform() async throws -> some IntentResult {
        return .result(dialog: IntentDialog("Test succeeded"))
    }
}

struct AppIntentsShortcutProvider: AppShortcutsProvider {
    static var appShortcuts: [AppShortcut] {
        return [
            AppShortcut(intent: SiriAppIntentsExtensionTest(),
                        phrases: ["Show my orders in \(.applicationName)",
                                  "Zeige meine Bestellungen in \(.applicationName)" ], // German translation for my evaluation
                        shortTitle: "Test", systemImageName: nil)
        ]
    }
}

Overall I think this feature is not used by any watchOS developers (but @szagun and me?). I will submit a radar/feedback to Apple.

You can see the confirmation dialog below:

This picture shows the Siri confirmation process

EDIT:

I actually got it working, the solution was rather simple.

  1. Remove the App Intents Extension completely.
  2. Add all Intents and shortcuts to the Apple Watch App Extension.
  3. Execute the shortcuts by saying the trigger phrase.
Sn0wfreeze
  • 1,959
  • 3
  • 18
  • 32