OpenSwiftUIProject / OpenSwiftUI

[WIP] Open source implementation of Apple's SwiftUI.
https://swiftpackageindex.com/OpenSwiftUIProject/OpenSwiftUI/main/documentation/openswiftui
MIT License
912 stars 27 forks source link

_UIHostingView deinit crash #87

Open Kyle-Ye opened 4 months ago

Kyle-Ye commented 4 months ago
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: a16685133110c11b24d8af779c3caf90a7124ccc

Kyle-Ye commented 4 months ago

Workaround this partially by #88