AppShortcutsProvider limitedAvailability in result builder crash

My team is preparing for iOS 18, and wanted to add intents using assistant schemas that are iOS 18 and above restricted.

We noticed that the result builder for AppShortcuts added support for limitedAvailabilityCondition from iOS 17.4 so we marked the whole struct as available from it.

The app compiles but writing a check like below inside appShortcuts property a crash will happen in iOS 17.5 runtime. (Removing the #available) is solving this problem.

        if #available(iOS 18, *) {
                    AppShortcut(
                        intent: SearchDonut(),
                        phrases: [
                            "Search for a donut in \(.applicationName)"
                        ],
                        shortTitle: "search",
                        systemImageName: "magnifyingglass"
                    )
                }

We tried out putting the os check above and returning shortcuts in arrays and that both compiles and runs but then AppShortcuts.strings sends warnings that the phrases are not used (This phrase is not used in any App Shortcut or as a Negative Phrase.) because the script that extracts the phrases somehow fails to perform when shortcuts are written like below:

static var appShortcuts: [AppShortcut] {
        if #available(iOS 18.0, *) {
            return [
                AppShortcut(
                    intent: CreateDonutIntent(),
                    phrases: [
                        "Create Donut in \(.applicationName)",
                    ],
                    shortTitle: "Create Donut",
                    systemImageName: "pencil"
                )
            ]
        } else {
            return [
                AppShortcut(
                    intent: CreateDonutIntent(),
                    phrases: [
                        "Create Donut in \(.applicationName)",
                    ],
                    shortTitle: "Create Donut",
                    systemImageName: "pencil"
                )
            ]
        }
    }

This is very problematic because we can't test out on TF with external users new intents dedicated for iOS 18.

We filed a radar under FB15010828

AppShortcutsProvider limitedAvailability in result builder crash
 
 
Q