I put together a simple project to build upon understand using classes and structs in swift. I recieve the following warning when running this code on the simulator:
ContentView.swift
import SwiftUI
struct ContentView: View {
@EnvironmentObject var app: App
var body: some View {
VStack{
ForEach(app.users.names, id: \.self) { name in
Text("\(name)")
}
Spacer()
Button(action: {self.app.users.add()}) {
Text("add")
}
}
}
}
class App: ObservableObject {
@Published var users = Users()
}
struct Users {
var names = ["Mac", "Alex", "Kevin"]
mutating func add() {
names.append("NEW GUY")
}
}
SceneDelegate.swift
var app = App()
let contentView = ContentView().environmentObject(app)
output:
2019-10-23 14:55:51.207032-0500 ExtendedClassDemo[43035:1908988] [AXRuntimeCommon] class 'SwiftUI.AccessibilityNode' is not a known serializable element and returning it as an accessibility element may lead to crashes
The warning appears when running on a simulator. It pops up on the initial down click of the add button. If I run on an actual device I don't receive the warning. I'm concluding it is a simulator issue not an actual device issue.
An explanation of why this warning is produced and any suggestions to improve my implementation are most appreciated.