I have this code, see below, it contains a ForEach loop which is commented out. the same view in an App runs just fine even if the ForEach loop is enabled. However, in a playground it crashes with a very unhelpful error message: "error: Playground execution aborted: error: Execution was interrupted, reason: signal SIGABRT. The process has been left at the point where it was interrupted, use "thread return -x" to return to the state before expression evaluation."
I tried finding information about this message. From what I understand it means that lldb does not know exactly what goes wrong and prints this. So, I turn to stack overflow in the hope someone does know what exactly might by going wrong here....?
import Cocoa
import SwiftUI
import PlaygroundSupport
import Combine
struct RowModel : Identifiable, Hashable {
var text : String
var id : UUID = UUID()
}
class My : ObservableObject {
@Published var s: String = "Hi there"
@Published var elements = [
RowModel(text: "een"),
RowModel(text: "twee"),
RowModel(text: "drie"),
RowModel(text: "vier"),
]
}
struct Row : View {
var item : String
var body : some View {
Text(item)
}
}
struct Screen : View {
@StateObject var my = My()
var body: some View {
VStack {
Text("The screen")
VStack {
Row(item: my.elements[0].text)
Row(item: my.elements[1].text)
// ForEach(0 ..< my.elements.count, id: \.self){ (index : Int) in
//
// Row(item: my.elements[index].text)
// }
}.frame(height: 100)
TextField("enter values", text: $my.s)
}
}
}
var view = Screen()
PlaygroundPage.current.setLiveView(view)
I'm late to the party, but this bug is still not fixed at this point so I figured I'd leave this for any future viewer.
This seems to be an issue with results bar on the right, because moving the view to a separate file in Sources (press Command 0) works fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With