Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to setup an iOS 17 interactive Widget using AppIntents from an SPM package?

I've setup an interactive 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!

like image 215
Mattias Farnemyhr Avatar asked Sep 05 '25 08:09

Mattias Farnemyhr


1 Answers

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.

like image 100
Mattias Farnemyhr Avatar answered Sep 08 '25 17:09

Mattias Farnemyhr