Could not find intent for LiveActivity Button

I show some content in LiveActivity Dynamic Island and added a button. As buttons work with App Intent I created an Intent. When the button is clicked I get the following error

Could not find an intent with identifier MyIntent, mangledTypeName: Optional("19LiveWidgetExtension10MyIntentV")

MyIntent.swift

import Foundation
import AppIntents

struct MyIntent: LiveActivityIntent {
     
    public init() { }
    
    func perform() async throws -> some IntentResult {
        print("click")
        return .result()
    }
}

MyLiveActivity.swift

... 
DynamicIslandExpandedRegion(.bottom) {
                    HStack(alignment: .top) {
                      Button(intent: MyIntent()) {
                            Image(systemName: "bolt.fill")
                           }
                          }
                          .tint(.white)
                          .padding()
                }
....

The Intent is added to all targets. Any ideas?

  • How can I register the Intent? Do I have to put something in the plist file?

  • How can I register the Intent? Do I have to put something in the plist file?

Add a Comment