I'm having an issue where iOS devices running iOS 14 are crashing, at first it was happening on the first view, so I decided I could probably live without the functionality and removed it, which worked, but then the same error happened in the next screen (one from a Sheet, the other from a NavigationView). I am unable to reproduce the error on physical devices deployed directly from Xcode (13.2 and 13.3) or in the simulator.
One of the instances is the following (I stripped some things out for simplicity, just to show how I'm using it)
struct TimeView: View {
@State var time: Double
var body: some View {
VStack{
if #available(iOS 15.0, *) {
TimeEditorView
} else {
TimeEditorView14
}
}
@available(iOS 15.0, *)
var TimeEditorView: some View {
TextField(Constants.Times.emptyTextHours, value: $time, format: .number)
.keyboardType(.decimalPad)
}
var TimeEditorView14: some View {
Text("\(time)")
}
}
Since it's completely different code in different places, I'm thinking maybe it's a bug or a project setting or something like that (if I am using it wrong I would think it would crash locally).
#0 (null) in closure #1 in TimeView.body.getter () #1 0x0000000102bdb190 in init at #2 (null) in body.get () #3 (null) in protocol witness for View.body.getter in conformance TimeView () #4 (null) in partial apply for closure #1 in ViewBodyAccessor.updateBody(of:changed:) () #5 (null) in closure #1 in BodyAccessor.setBody(_:) () #6 (null) in ViewBodyAccessor.updateBody(of:changed:) ()
Any suggestions of things to try are welcome, thanks!
Edit: corrected the second view variable name