9

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.

Mac Wayne
  • 587
  • 4
  • 13
  • 1
    For what it's worth, this sounds like it was an early SwiftUI or iOS bug. Running this code with an iOS 13.3 simulator doesn't log any warning/error. – Seb Jachec Jan 06 '20 at 15:46
  • 2
    This warning comes and goes from time to time. Here's a bit more investigation: https://stackoverflow.com/questions/58449530/catalyst-swiftui-accessibilitynode-is-not-a-known-serializable-element Basic answer: Don't worry just ignore. – jboi Feb 16 '20 at 13:15

0 Answers0