I'm trying to dynamically build a view using SwiftUI for my widget. However, when multiple views are stacked, the widget no longer works. I want to loop my Widget over an array of fetched data, like so:
VStack {
ForEach(entry.layers.indices) { index in
let layer = entry.layers[index]
Text(layer)
}
}
but this doesnt work properly when the forEach loops more than about 5 times (it works fine when only looping once or twice!). I contacted Apple Code Level Support about this and they told me this is a 'bug'. See the example project I provided: https://github.com/swifty-on-me/Widget-Example
This is the data I'm trying to render: https://github.com/swifty-on-me/Widget-Example/blob/main/Data/FakeData.swift
I tried something like converting a view to image but the solution doesn't work in Extensions.
So I found this 'workaround' on the Apple Developer Forums but I'm unsure how to implement it: https://developer.apple.com/forums/thread/665935
Could someone explain or guide me to this workaround? (I'm not so at home with Swift(UI))
I've been messing around with this for ages now and I think I'm going insane about what seems like such a simple task.
See this example (about 28 seconds)
