Hi all,
I’m seeing what looks like a bug with AppShortcutParameterPresentation and the Shortcuts app. Any time I provide an OptionsCollection to a shortcut so I can give it a nice category name and symbol in Shortcuts, it hides all other existing app shortcuts that my app has from the UI.
I have created a sample that illustrates the problem.
My app provides two App Shortcuts:
- A simple shortcut with no parameters.
- A shortcut with two parameters. Its
Destinationparameter usesAppShortcutParameterPresentationto generate “Home” and “Office” options in a separate section.
When the second shortcut is present, the first parameterless shortcut disappears from the Shortcuts app. If I comment out the shortcut containing parameterPresentation, the parameterless shortcut appears again.
Before commenting out:
After commenting out the second shortcut:
Here's the code:
import AppIntents
struct ParameterlessIntent: AppIntent {
static let title: LocalizedStringResource = "Parameterless Intent"
static let description = IntentDescription("Runs without asking for any parameters.")
func perform() async throws -> some IntentResult {
.result()
}
}
struct ParameterizedIntent: AppIntent {
static let title: LocalizedStringResource = "Parameterized Intent"
static let description = IntentDescription("Runs with a destination and a copy count.")
// The same provider is used by this parameter and by ParameterPresentation below.
@Parameter(
title: "Destination",
optionsProvider: DestinationOptionsProvider()
)
var destination: String
@Parameter(title: "Copy Count", default: 1)
var copyCount: Int
static var parameterSummary: some ParameterSummary {
Summary("Send \(\.$copyCount) copies to \(\.$destination)")
}
func perform() async throws -> some IntentResult {
.result()
}
}
nonisolated struct DestinationOptionsProvider: DynamicOptionsProvider {
func results() async throws -> [String] {
// Each generated App Shortcut option is a value for the Destination parameter.
["Home", "Office"]
}
}
struct BugReproductionShortcuts: AppShortcutsProvider {
static var appShortcuts: [AppShortcut] {
// This parameterless shortcut should always appear in the Shortcuts app.
AppShortcut(
intent: ParameterlessIntent(),
phrases: [
"Run the parameterless shortcut with \(.applicationName)"
],
shortTitle: "Do I exist?",
systemImageName: "1.circle"
)
#warning("The presence of this shortcut causes the top one no longer appear in Shortcuts.app")
AppShortcut(
intent: ParameterizedIntent(),
phrases: [
"Run the parameterized shortcut with \(.applicationName)"
],
shortTitle: "Parameterized Shortcut",
systemImageName: "2.circle",
parameterPresentation: ParameterPresentation(
for: \.$destination,
summary: Summary("Send to \(\.$destination)")
) {
// This title and symbol create a separate section in Shortcuts.
OptionsCollection(
DestinationOptionsProvider(),
title: "Destination Shortcuts",
systemImageName: "mappin.and.ellipse"
)
}
)
}
}
This code and reproduction is as of Xcode 27 Beta 6 and happens on older versions as well.
Is there a known limitation with this or is this somehow expected behavior? If so, how can I mitigate this issue and provide a nice title for another shortcut, while keeping the old parameterless shortcuts present?
Thanks!