diff --git a/ExampleApps/SwiftUIExample/SwiftUIExampleTests/UIKitInteropTests.swift b/ExampleApps/SwiftUIExample/SwiftUIExampleTests/UIKitInteropTests.swift index 154a2a92f..850f67cb1 100644 --- a/ExampleApps/SwiftUIExample/SwiftUIExampleTests/UIKitInteropTests.swift +++ b/ExampleApps/SwiftUIExample/SwiftUIExampleTests/UIKitInteropTests.swift @@ -99,13 +99,15 @@ final class UIKitInteropTests: XCTestCase, View { func testPuttingAUIKitViewThatDoesNotTakeInDataInsideASwiftUIWorkflow() async throws { final class FR1: UIWorkflowItem, FlowRepresentable { - let nextButton = UIButton() + let nextButtonTag = UUID().hashValue @objc private func nextPressed() { proceedInWorkflow() } override func viewDidLoad() { + let nextButton = UIButton() + nextButton.tag = nextButtonTag nextButton.setTitle("Next", for: .normal) nextButton.setTitleColor(.systemBlue, for: .normal) nextButton.addTarget(self, action: #selector(nextPressed), for: .touchUpInside) @@ -143,8 +145,9 @@ final class UIKitInteropTests: XCTestCase, View { proceedCalled.fulfill() } - XCTAssertEqual(vc.nextButton.willRespondToUser, true) - vc.nextButton.simulateTouch() + let nextButton = try XCTUnwrap(vc.view.viewWithTag(vc.nextButtonTag) as? UIButton) + XCTAssertEqual(nextButton.willRespondToUser, true) + nextButton.simulateTouch() wait(for: [proceedCalled], timeout: TestConstant.timeout) }