Catalyst 'SwiftUI.AccessibilityNode' is not a known serializable element

折月煮酒 提交于 2020-03-18 03:19:14

问题


I created a fresh iOS Single Page App (including SwiftUI) with Xcode 11.1 and enabled Mac Catalyst. After running the fresh Project on my Mac (macOS 10.15 of course) I get the following errors after tapping once on the window.

2019-10-18 12:59:48.479186+0200 test[3130:122148] Metal API Validation Enabled
2019-10-18 12:59:50.960734+0200 test[3130:122148] [AXRuntimeCommon] Unknown client: test
2019-10-18 12:59:50.962261+0200 test[3130:122148] [AXRuntimeCommon] This class 'SwiftUI.AccessibilityNode' is not a known serializable element and returning it as an accessibility element may lead to crashes
2019-10-18 12:59:51.313 test[3130:122148] **************_____________**************AXError: AVPlayerView is not a kind of NSView
1   AccessibilityBundles                0x00007fff42ee3b69 _AXBValidationCheckIsKindOfClass + 201
2019-10-18 12:59:51.386 test[3130:122148] **************_____________**************AXError: MKStarRatingView is not a kind of NSView
1   AccessibilityBundles                0x00007fff42ee3b69 _AXBValidationCheckIsKindOfClass + 201

Note: I also removed the Sandbox capability otherwise I get error about can't writing ApplicationAccessibilityEnabled

Does anyone know how to solve that?


回答1:


As far as I can tell, there isn't a way to get rid of that error, and there isn't a need to; it's something inherent in SwiftUI. It occurs on iOS, iPadOS, and (therefore) Mac Catalyst, even in a brand new project. It also doesn't seem to hurt anything, other than to worry us developers.

I've been working in SwiftUI for the past six months full-time on an app that is now in production running on iOS, iPadOS and MacOS (Catalyst). The This class 'SwiftUI.AccessibilityNode' is not a known serializable element error has been there since the beginning. I haven't traced it to be the source of any problem in six months of SwiftUI development.

If you open Xcode, create a new single-view iOS project, and run it without change, it'll display "Hello, World!". Click "Hello, World!" and your console will log [AXRuntimeCommon] This class 'SwiftUI.AccessibilityNode' is not a known serializable element and returning it as an accessibility element may lead to crashes.

I've tried adding accessibility modifiers, e.g.:

struct ContentView: View {
    var body: some View {
        Text("Hello, World!")
        .accessibility(hint: Text("Just say hi"))
        .accessibility(identifier: "helloWorld")
    }
}

The error still gets logged when I click "Hello, World!".

I've also tried extending SwiftUI.AccessibilityNode to make it a serializable element, e.g.:

import SwiftUI

extension SwiftUI.AccessibilityNode {
}

Xcode says type SwiftUI.AccessibilityNode doesn't exist.




回答2:


If you find them annoying as I do you can silence them as mentioned in this answer:

Hide strange unwanted Xcode logs



来源:https://stackoverflow.com/questions/58449530/catalyst-swiftui-accessibilitynode-is-not-a-known-serializable-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!