UIWindow.makeKeyAndVisible() throws “props must have a valid clientID” error in XCTest
问题 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] **