I have added an "App Intents Extension" target to my main application in macOS. This generated the below two files:
TWAppIntent.swift
import AppIntents
struct TWAppIntent: AppIntent {
static var title: LocalizedStringResource = "TWAppIntent"
static var parameterSummary: some ParameterSummary {
Summary("Get information on \(\.$TWType)")
}
// we can have multiple parameter of diff types
@Parameter(title: "TWType")
var TWType: String
func perform() async throws -> some IntentResult {
return .result(dialog: "Executed TWAppIntent.")
}
}
TWAppIntentExtension.swift
import AppIntents
@main
struct TWAppIntentExtension: AppIntentsExtension {
}
I m able to build the extension target and I my intent action is available in the shortcuts app. However, on launching a shortcut with the above created intent action. I m getting the below popups:
From what I understand, I m getting this error because I have not added my 'TWAppIntent' to the TWAppIntentExtension.swift file which is the entry point for the extension, but I could not find any documentation around how to add it. Can someone help on how to do it or Is there something else that I m doing wrong?
Hey!
I added your AppIntent to my AppIntentExtension and the problem isn't the @main the problem is that as soon as your app intent calls perform it crashes
The big issue with AppIntentExtension that it is impossible to debug it. So if your app succeeded to extract metadata it means the rest fails on your interactions , it may help you later to trace the errors which unfortunately for now we can't see.
Let's get back to your AppIntent, it crashes your app and your extension because your result returns dialog, which you didn't precise in return type of your perform.
Adding ProvidesDialog solve the problem.
Good luck:)