Skip to content

Commit 9e43b85

Browse files
committed
Workaround Issue 87
1 parent 66f5527 commit 9e43b85

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

Tests/OpenSwiftUICompatibilityTests/Integration/UIKit/UIHostingController+Helper.swift

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,21 @@ extension UIHostingController {
1313
view.layoutSubviews()
1414
}
1515
}
16+
17+
// FIXME: A workaround to bypass the Issue #87
18+
func workaroundIssue87(_ vc: UIViewController) {
19+
if compatibilityTestEnabled {
20+
return
21+
} else {
22+
// TODO: Use swift-test exist test feature to detect the crash instead or sliently workaroun it
23+
CrashWorkaround.shared.objects.append(vc)
24+
}
25+
}
26+
27+
private final class CrashWorkaround {
28+
private init() {}
29+
static let shared = CrashWorkaround()
30+
var objects: [Any?] = []
31+
}
32+
1633
#endif

Tests/OpenSwiftUICompatibilityTests/Integration/UIKit/UIHostingControllerTests.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ struct UIHostingControllerTests {
1818
}
1919
let vc = UIHostingController(rootView: ContentView())
2020
vc.triggerLayout()
21+
workaroundIssue87(vc)
2122
}
2223

2324
@Test("BodyAccessor crash for non empty View instance", .bug("#81", relationship: .verifiesFix))
@@ -30,6 +31,7 @@ struct UIHostingControllerTests {
3031
}
3132
let vc = UIHostingController(rootView: ContentView())
3233
vc.triggerLayout()
34+
workaroundIssue87(vc)
3335
}
3436
}
3537
#endif

Tests/OpenSwiftUICompatibilityTests/View/Debug/ChangedBodyPropertyTests.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ struct ChangedBodyPropertyTests {
2222
#if os(iOS)
2323
let vc = UIHostingController(rootView: ContentView())
2424
vc.triggerLayout()
25+
workaroundIssue87(vc)
2526
#endif
2627
}
2728

@@ -38,6 +39,7 @@ struct ChangedBodyPropertyTests {
3839
#if os(iOS)
3940
let vc = UIHostingController(rootView: ContentView())
4041
vc.triggerLayout()
42+
workaroundIssue87(vc)
4143
#endif
4244
}
4345

@@ -54,6 +56,7 @@ struct ChangedBodyPropertyTests {
5456
#if os(iOS)
5557
let vc = UIHostingController(rootView: ContentView())
5658
vc.triggerLayout()
59+
workaroundIssue87(vc)
5760
#endif
5861
}
5962
}

0 commit comments

Comments
 (0)