macosappintents

Basic app intent always showing error in Shortcuts app "The action could not run because an internal error occurred."


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.".

enter image description here

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()
    }
}

Solution

  • 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:

    1. Open your project in Xcode.

    2. Select the Swift file where OpenAppIntent is defined (e.g., OpenAppIntent.swift).

    3. 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).