I'm surprised this even compiles. On iOS 18 beta 3 I get the following error:
Closure containing control flow statement cannot be used with result builder 'AppShortcutsBuilder'
So there is currently no way to include an app shortcut for a specific iOS version (iOS 17 or iOS 18). Not sure what to do at this point...