Hi,
I am trying to integrate the new AppIntentsPackage
protocol into my application. Especially what I want to do is to create a dedicate SPM package which holds all my app intents and then share that with my widget extension for Widget intents as well as the main iOS app for powering an AppShortcutProvider
. Unfortunately I run into an issue here.
I have the following explanatory setup:
- SPM package called
ProjectAppIntents
- iOS target
My AppIntents SPM package
//Package: ProjectAppIntents
public struct TestAppIntent: AppIntent {
public static var title: LocalizedStringResource = "TestAppIntent"
@Parameter(title: "Parameter1", optionsProvider: ParameterOptionProvider())
public var parameter: String
public init(parameter: String) {
self.parameter = parameter
}
public init() { }
public func perform() async throws -> some IntentResult & ReturnsValue {
.result(value: 5)
}
}
struct ParameterOptionProvider: DynamicOptionsProvider {
func results() async throws -> [String] {
return ["Hello", "World"]
}
}
public struct ProjectAppIntentsPackage: AppIntentsPackage { }
My iOS app
// Target: iOS
import ProjectAppIntents
struct ProjectApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
extension ProjectApp: AppIntentsPackage {
static var includedPackages: [AppIntentsPackage.Type] = [
ProjectAppIntentsPackage.self
]
}
struct ProjectShortcuts: AppShortcutsProvider {
static var appShortcuts: [AppShortcut] {
AppShortcut(
intent: TestAppIntent(),
phrases: ["Start a \(.applicationName)"],
shortTitle: "Hello World",
systemImageName: "house"
)
}
}
When I now try to compile my app, I get the following build error:
2023-06-25 09:53:47.853 appintentsnltrainingprocessor[44848:2059163] Parsing options for appintentsnltrainingprocessor
2023-06-25 09:53:47.854 appintentsnltrainingprocessor[44848:2059163] Starting AppIntents SSU YAML Generation
2023-06-25 09:53:47.868 appintentsnltrainingprocessor[44848:2059163] error: The action TestAppIntent referenced in App Shortcut does not exist
Command AppIntentsSSUTraining failed with a nonzero exit code
So for me it seems like the compiler cannot find the AppIntent defined in an SPM package.
Am I doing something wrong here or does the AppIntentsPackage
protocol not work with SPM packages ?
Thanks a lot for helping !