Ryan Ashcraft @ryanashcraft.com · Apr 7

SwiftUI help needed! My app has a crash in its widgets extension, related to a ForEach. Can't figure out what's causing it and I'm not sure how to repro. No user reports of any issues, but there's a large volume of crashes. Stack trace isn't the most helpful. Anyone dealt with something similar?

4 likes 4 replies

?

Replies

Greg Gardner · Apr 8

ForEach will crash if you have duplicate ids in the array. I would look into whether or not that is a possibility.

Roman · Apr 7

It was long ago but I remember I had issues with ForEach when the array passed in didn’t have any values. It shouldn’t be like this but yet it was. if !array.isEmpty { solved the issue for me

Majid Jabrayilov · Apr 8

Verify that ids in the ForEach are unique.

Adam Wulf · Apr 7

How are you managing threading? My gut says it looks like the backing array changed out from under it during the foreach