So I going along merrily attempting to write the code for Day 19 Challenge and then I get a Swift compiler error as follows:
"Failed to produce diagnostic for expression; please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project"
The expression is: var body: some View {
So basically I'm dead in the water. There are no other errors that pop up but the project will not build because of the compiler error.
What can I do so I can continue coding and testing the project?
My code so far...
import SwiftUI
struct ContentView: View {
@State private var inputValue = 0.0
@State private var inputUnit = ""
@State private var outputUnit = ""
var outputValue = 0.0
var baseUnitValue = 0.0
var units = ["meters","kilometers", "feet", "yard", "miles"]
@FocusState private var inputFieldIsFocused: Bool
var body: some View {
NavigationView {
Form {
Section {
Picker("Starting Unit", selection: $inputUnit) {
ForEach(units, id: \.self) {
Text($0, format: .number)
}
}
.pickerStyle(.segmented)
}
Section {
Picker("Ending Unit", selection: $outputUnit) {
ForEach(units, id: \.self) {
Text($0, format: .number)
}
}
}
.pickerStyle(.segmented)
Section {
TextField("Enter the value to convert", value: $inputValue, format: .number)
.keyboardType(.decimalPad)
.focused($inputFieldIsFocused)
}
Section {
Text(outputValue, format: .number)
}
} .navigationTitle("UnitConverter")
.navigationBarTitleDisplayMode(.inline)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}