I have a very basic App Intent extension in my macOS app that does nothing than accepting two parameters, but running it in Shortcuts always produces the error "The action “Compare” could not run because an internal error occurred.".
What am I doing wrong?
struct CompareIntent: AppIntent {
static let title = LocalizedStringResource("intent.compare.title")
static let description = IntentDescription("intent.compare.description")
static let openAppWhenRun = true
@Parameter(title: "intent.compare.parameter.original")
var original: String
@Parameter(title: "intent.compare.parameter.modified")
var modified: String
func perform() async throws -> some IntentResult {
return .result()
}
}
I had the same issue and found that the error was in this line.
static let openAppWhenRun = true
To fix it move your Intent with the OpenAppIntent to your app’s main target, follow these steps in Xcode:
Open your project in Xcode.
Select the Swift file where OpenAppIntent is defined (e.g., OpenAppIntent.swift).
In the File Inspector (right sidebar), check the Target Membership section:
Ensure your main app target is checked.
Uncheck any other targets (e.g., widgets, extensions).