OpenSwiftUIProject / OpenSwiftUI

[WIP] Open source implementation of Apple's SwiftUI.

Home Page:https://swiftpackageindex.com/OpenSwiftUIProject/OpenSwiftUI/main/documentation/openswiftui

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

_UIHostingView deinit crash

Kyle-Ye opened this issue · comments

commented
image
@MainActor
@Test
func testDemo() throws {
    struct ContentView: View {
        var name = ""
        var body: some View {
            AnyView(EmptyView())
        }
    }
    let vc = UIHostingController(rootView: ContentView())
    vc.triggerLayout()
}
extension UIHostingController {
    func triggerLayout() {
        let window = UIWindow(frame: CGRect(x: 0, y: 0, width: 100, height: 100))
        window.rootViewController = self
        window.makeKeyAndVisible()
        view.layoutSubviews()
    }
}

Commit Hash: a166851

commented

Workaround this partially by #88