twostraws / ControlRoom

A macOS app to control the Xcode Simulator.
MIT License
5.77k stars 304 forks source link

Getting compile errors when building #72

Closed boherna closed 4 years ago

boherna commented 4 years ago

Hi, any ideas why I'm getting these errors. Thanks.

Screenshot 2020-03-03 at 14 03 09
thibmaek commented 4 years ago

Seeing the same errors here:

CypherPoet commented 4 years ago

I ran across the same issue, and I was able to trace it to this line:

Text(String(format: "%.2f", value))

If, instead, I use NumberFormatter to generate a string from value, Text will take it just fine:

    private static let numberFormatter: NumberFormatter = {
        let formatter = NumberFormatter()

        formatter.numberStyle = .decimal
        formatter.minimumFractionDigits = 2
        formatter.maximumFractionDigits = 2

        return  formatter
    }()

    ...

    var body: some View {
        HStack {
            Slider(value: $value, label: { Text(title) })
            Text(sliderDisplayValue)
        }
        .disabled(!isEnabled)
        .addingInfoButton(title: title, description: description)
    }

    var sliderDisplayValue: String {
        Self.numberFormatter.string(for: value) ?? ""
    }