I'm currently trying to use the new @UnionValue
macro.
From what I understood, it allows multiple types for a parameter.
I created the following enum:
@UnionValue
enum IntentDuration {
case int(Int)
case duration(Measurement<UnitDuration>)
}
Then, I tried to use it in the following AppIntent:
struct MyIntent: AppIntent {
static let title: LocalizedStringResource = "intent.title"
static let description = IntentDescription("intent.description")
static let openAppWhenRun: Bool = true
@Parameter var duration: IntentDuration
@Dependency
private var appManager: AppManager
@MainActor
func perform() async throws -> some IntentResult {
// My action
return .result()
}
}
However, I get the following error from Xcode at the @Parameter
line:
'init()' is unavailable
Did I wrongly understand how this works? Is there another way to accept multiple types for a parameter?
I didn't manage to find any docs on this.