1

I've setup an intractable Widget in iOS 17 which uses an AppIntent from an SPM package but nothing works when you tap on the button in the widget.

Supposedly you should be able to use AppIntentsPackage, which should make it possible to use AppIntents from other frameworks/SPM package(?), but I cannot get it to work. This is my setup:

SPMPackage

public struct MyAppIntent: AppIntent { ... }

public struct MyAppIntentPackage: AppIntentsPackage { }

WidgetExtension

import SPMPackage

struct MyWidgetEntryView: View {
    var body: some View {
        Button(intent: MyAppIntent()) {
            Text("Tap here")
        }
        .containerBackground(...)
    }
}

extension MyWidgetBundle: AppIntentsPackage {
    static var includedPackages: [AppIntentsPackage.Type] = [
        MyAppIntentPackage.self
    ]
}

Seems to have set it up exactly how Apple explains it in the documentation but it doesn't work. Am I missing something? Thanks!

Mattias Farnemyhr
  • 4,148
  • 3
  • 28
  • 49

1 Answers1

1

Got word back from an Apple representative that having AppIntents in an SPM package is not yet supported.

I solved my issue by moving all the code related to AppIntents in to the WidgetExtension and now it works reliably.

Hope this helps someone else in the future, but more hopeful that this will be resolved in a future iOS version.

Mattias Farnemyhr
  • 4,148
  • 3
  • 28
  • 49