I am trying to build an AppIntent (iOS 16) with a parameter where the user can enter data in the shortcuts app. The code looks like that:
import Foundation
import AppIntents
struct MyIntent: AppIntent {
static var title = LocalizedStringResource("Intent title")
@Parameter(title: "user value", default: "not set")
var myParameterVariableName: String
static var parameterSummary: some ParameterSummary {
Summary("Your Value: \(\.$myParameterVariableName)")
}
@MainActor func perform() async throws -> some IntentResult {
print("action")
return .result()
}
}
Which looks as expected in the shortcuts app when I try to configure a shortcut with that intent:
However, the parameter's default value should be different based on the active build configuration. So I tried this:
#if DEBUG
@Parameter(title: "user value", default: "debug")
var myParameterVariableName: String
#else
@Parameter(title: "user value", default: "not set")
var myParameterVariableName: String
#endif
But this leads to displaying the variable name in the shortcuts app:
It does not display "debug" or "not set" as the default value no matter which build configuration i choose to build. I can tap on it and enter data, but the default value is not displayed.
Any ideas? Are there other ways to replaces variables that to use preprocessor macros?
This has been fixed in Xcode 15 beta. Compiler conditionals are working now in App intents.