SwiftUI accessibility when embedded in UIKit

Hello,

I struggle to do some UI testing using accessibility identifiers when I wrap some SwiftUI view using UIHostingController (our app is mainly coded using UIKit).

Considering this SwiftUI view (simplified for this post):

        HStack {
            Text(self.title.uppercased())
                .albusTheme(.header)
                .lineLimit(self.isMultiline ? nil : 1)
                .multilineTextAlignment(.leading)
                .accessibilityAddTraits(.isStaticText)
                .accessibilityIdentifier("section_title")

        }

This view and its controller are embedded as a UITableViewHeaderFooterView in a UITableView.

This is an extract of recursiveDescription output:

   |    |    |    |    |    | <_UITableViewHeaderFooterContentView: 0x1076ad720; frame = (0 0; 393 40); layer = <CALayer: 0x6000006b1720>>
   |    |    |    |    |    |    | <_TtGC13ListComponent19SwiftUIFieldContentV20ListComponentLibrary17FormSectionHeader_: 0x1076ab980; baseClass = UIControl; frame = (0 0; 393 40); layer = <CALayer: 0x6000006b1da0>>
   |    |    |    |    |    |    |    | <_TtGC7SwiftUI14_UIHostingViewV20ListComponentLibrary17FormSectionHeader_: 0x1078f9600; frame = (0 0; 393 40); gestureRecognizers = <NSArray: 0x600000e25d70>; backgroundColor = UIExtendedSRGBColorSpace 0.0666667 0.133333 0.227451 1; layer = <SwiftUI.UIHostingViewDebugLayer: 0x6000006b19a0>>
   |    |    |    |    |    |    |    |    | <_TtCOCV7SwiftUI11DisplayList11ViewUpdater8Platform13CGDrawingView: 0x106985550; frame = (16 12.6667; 147.667 14.6667); anchorPoint = (0, 0); opaque = NO; autoresizesSubviews = NO; layer = <_TtCOCV7SwiftUI11DisplayList11ViewUpdater8PlatformP33_65A81BD07F0108B0485D2E15DE104A7514CGDrawingLayer: 0x6000026b8240>>

CGDrawingView seems to hide the underlying view hierarchy. Is there a way to access accessibility settings using the integration of SwiftUI in UIKit?

I'm having the same issue. TextFields appear in my UI testing tool but any Text element is hidden behind a CGDrawingView.

SwiftUI accessibility when embedded in UIKit
 
 
Q