UIWindow.makeKeyAndVisible() throws “props must have a valid clientID” error in XCTest

强颜欢笑 提交于 2019-12-12 14:28:49

问题


I am testing a UIViewController in Xcode with an XCTest. In order to test some navigation and alert functionality I need to put my view controller in a UIWindow. I do so with the following code:

let myViewController = UIViewController()
let window = UIWindow(frame: UIScreen.main.bounds)
window.rootViewController = myViewController
window.makeKeyAndVisible()

However when makeKeyAndVisible() is called my test fails with the following error:

2018-01-04 10:56:31.068462-0500 xctest[7858:315680] *** Assertion failure in -[BKSEventFocusManager deferEventsForClientWithProperties:toClientWithProperties:withPriority:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/BackBoardServicesFramework_Sim/backboarddaemon-193/BackBoardServices/BKSEventFocusManager.m:168 :0: error: -[MyTests.MyViewControllerTests testDoneTapped_dismissesViewController] : failed: caught "NSInternalInconsistencyException", "props must have a valid clientID"

Can anyone provide a solution or tell me what

"props must have a valid clientID" means?

来源:https://stackoverflow.com/questions/48099154/uiwindow-makekeyandvisible-throws-props-must-have-a-valid-clientid-error-in

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!