Xcode: 11.2.1
The code below is for a simple form with two components; a Picker (to select a letter) and a Text (to display the selected letter). The code compiles
ForEach types inside Picker should be aligned with selection type.
Here is a corrected code that should work for you:
@State private var letter = ""
private let letters = ["Alpha", "Bravo", "Charlie"]
var body: some View {
NavigationView {
Form {
Picker("Select a letter", selection: $letter) {
ForEach(letters, id: \.self) { option in
Text(option)
}
}
Text("Selected letter: \(letter)")
}
.navigationBarTitle("Main Menu")
}
}