I have a crash report and I can’t figure out how to fix it, probably the main issue is that it's the first time I receive a crash report so I‘m not that expert on using it! (…so please, be kind!)
Basically it's a bug that I can't replicate but Apple tells me that there're two iPhones around the world with this issue.
That’s the crash report:
The red line brings to the .environment line in this code
@AppStorage("isLocalTime") var isLocalTime: Bool = false
HStack {
DatePicker(selection: $selectedDate, label: { more code })
Text(isLocalTime ? "LT" : "UTC")
.frame(width: 44)
}
.environment(\.timeZone, TimeZone(abbreviation: isLocalTime ? TimeZone.current.abbreviation()! : "UTC")!)
.datePickerStyle(.automatic)
It is a line who sets the timezone of a date picker on device local time or UTC, according to a bool setting.
Luckily, I’m in contact with one of the users who has the issue and she reported me that, as soon as she launch the screen, the app crashes. I tried to set her timezone but that’s not the issue as it works smooth for me, what can be wrong? How can I replicate this bug?
Now that I'm writing here, I realised that the incriminated line should be below the DatePicker's code but, right now, it works anyway, so it should not be the cause of the bug I think...
I have a crash report and I can’t figure out how to fix it, probably the main issue is that it's the first time I receive a crash report so I‘m not that expert on using it! (…so please, be kind!)
Basically it's a bug that I can't replicate but Apple tells me that there're two iPhones around the world with this issue.
That’s the crash report:
The red line brings to the .environment line in this code
@AppStorage("isLocalTime") var isLocalTime: Bool = false
HStack {
DatePicker(selection: $selectedDate, label: { more code })
Text(isLocalTime ? "LT" : "UTC")
.frame(width: 44)
}
.environment(\.timeZone, TimeZone(abbreviation: isLocalTime ? TimeZone.current.abbreviation()! : "UTC")!)
.datePickerStyle(.automatic)
It is a line who sets the timezone of a date picker on device local time or UTC, according to a bool setting.
Luckily, I’m in contact with one of the users who has the issue and she reported me that, as soon as she launch the screen, the app crashes. I tried to set her timezone but that’s not the issue as it works smooth for me, what can be wrong? How can I replicate this bug?
Now that I'm writing here, I realised that the incriminated line should be below the DatePicker's code but, right now, it works anyway, so it should not be the cause of the bug I think...
Share Improve this question edited Mar 15 at 10:19 Matte.Car asked Mar 15 at 9:56 Matte.CarMatte.Car 2,0415 gold badges24 silver badges42 bronze badges 2
isLocalTime ? TimeZone.current : TimeZone.gmt
? – Sweeper Commented Mar 15 at 10:03