From f8b3a16d486593fc4c495ab9d2f89db32ac8bb22 Mon Sep 17 00:00:00 2001 From: Kyle Date: Mon, 14 Sep 2026 04:56:19 +0800 Subject: [PATCH] fix(hosting): avoid false AppKit subview warnings --- .../Hosting/AppKit/View/NSHostingView.swift | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/Sources/OpenSwiftUI/Integration/Hosting/AppKit/View/NSHostingView.swift b/Sources/OpenSwiftUI/Integration/Hosting/AppKit/View/NSHostingView.swift index 8589471dc..b0943cf9f 100644 --- a/Sources/OpenSwiftUI/Integration/Hosting/AppKit/View/NSHostingView.swift +++ b/Sources/OpenSwiftUI/Integration/Hosting/AppKit/View/NSHostingView.swift @@ -926,8 +926,18 @@ open class NSHostingView: NSView, XcodeViewDebugDataProvider where Cont // TODO: handle screen change } - @objc(swiftui_addRenderedSubview:positioned:relativeTo:) // FIXME: ViewUpdater -> AppKitAddSubview - private func openswiftui_addRenderedSubview(_ view: NSView, positioned place: NSWindow.OrderingMode, relativeTo otherView: NSView?) { + @_spi(ForOpenSwiftUIOnly) + #if OPENSWIFTUI_SWIFTUI_RENDERER + @objc(swiftui_addRenderedSubview:positioned:relativeTo:) + #endif + override public func openswiftui_addRenderedSubview( + _ subview: Any, + positioned place: Int, + relativeTo otherView: Any? + ) { + let view = subview as! NSView + let place = NSWindow.OrderingMode(rawValue: place)! + let otherView = otherView as! NSView isInsertingRenderedSubview = true addSubview(view, positioned: place, relativeTo: otherView) isInsertingRenderedSubview = false