Skip to content

Commit

Permalink
Workaround Issue 87
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle-Ye committed Apr 27, 2024
1 parent 66f5527 commit 9e43b85
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,21 @@ extension UIHostingController {
view.layoutSubviews()
}
}

// FIXME: A workaround to bypass the Issue #87
func workaroundIssue87(_ vc: UIViewController) {
if compatibilityTestEnabled {
return
} else {
// TODO: Use swift-test exist test feature to detect the crash instead or sliently workaroun it
CrashWorkaround.shared.objects.append(vc)
}
}

private final class CrashWorkaround {
private init() {}
static let shared = CrashWorkaround()
var objects: [Any?] = []
}

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ struct UIHostingControllerTests {
}
let vc = UIHostingController(rootView: ContentView())
vc.triggerLayout()
workaroundIssue87(vc)
}

@Test("BodyAccessor crash for non empty View instance", .bug("#81", relationship: .verifiesFix))
Expand All @@ -30,6 +31,7 @@ struct UIHostingControllerTests {
}
let vc = UIHostingController(rootView: ContentView())
vc.triggerLayout()
workaroundIssue87(vc)
}
}
#endif
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ struct ChangedBodyPropertyTests {
#if os(iOS)
let vc = UIHostingController(rootView: ContentView())
vc.triggerLayout()
workaroundIssue87(vc)
#endif
}

Expand All @@ -38,6 +39,7 @@ struct ChangedBodyPropertyTests {
#if os(iOS)
let vc = UIHostingController(rootView: ContentView())
vc.triggerLayout()
workaroundIssue87(vc)
#endif
}

Expand All @@ -54,6 +56,7 @@ struct ChangedBodyPropertyTests {
#if os(iOS)
let vc = UIHostingController(rootView: ContentView())
vc.triggerLayout()
workaroundIssue87(vc)
#endif
}
}

0 comments on commit 9e43b85

Please sign in to comment.