Вот возможное решение. Протестировано с Xcode 11.4 / iOS 13.4
с вспомогательной функцией
func generateActionSheet(options: [String]) -> ActionSheet {
let buttons = options.enumerated().map { i, option in
Alert.Button.default(Text(option), action: { self.option = i + 1 } )
}
return ActionSheet(title: Text("Select an option"),
buttons: buttons + [Alert.Button.cancel()])
}
, затем вы можете использовать
.actionSheet(isPresented: self.$showSheet, content: {
// assuming you have `currentOptions` (or similar) property for dynamic
// options
self.generateActionSheet(options: self.currentOptions)
})