Skip to content

Commit dbd2dfb

Browse files
authored
fix(hosting): avoid false AppKit subview warnings (#1081)
1 parent a321de1 commit dbd2dfb

1 file changed

Lines changed: 12 additions & 2 deletions

File tree

Sources/OpenSwiftUI/Integration/Hosting/AppKit/View/NSHostingView.swift

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -926,8 +926,18 @@ open class NSHostingView<Content>: NSView, XcodeViewDebugDataProvider where Cont
926926
// TODO: handle screen change
927927
}
928928

929-
@objc(swiftui_addRenderedSubview:positioned:relativeTo:) // FIXME: ViewUpdater -> AppKitAddSubview
930-
private func openswiftui_addRenderedSubview(_ view: NSView, positioned place: NSWindow.OrderingMode, relativeTo otherView: NSView?) {
929+
@_spi(ForOpenSwiftUIOnly)
930+
#if OPENSWIFTUI_SWIFTUI_RENDERER
931+
@objc(swiftui_addRenderedSubview:positioned:relativeTo:)
932+
#endif
933+
override public func openswiftui_addRenderedSubview(
934+
_ subview: Any,
935+
positioned place: Int,
936+
relativeTo otherView: Any?
937+
) {
938+
let view = subview as! NSView
939+
let place = NSWindow.OrderingMode(rawValue: place)!
940+
let otherView = otherView as! NSView
931941
isInsertingRenderedSubview = true
932942
addSubview(view, positioned: place, relativeTo: otherView)
933943
isInsertingRenderedSubview = false

0 commit comments

Comments
 (0)