XCUIElement tap() not working

So an Apple engineer responded to my bug report saying:

The second possibility is that you are running into a problem that sometimes occurs where the application finishes launching but the splash screen doesn't immediately disappear and events dispatched to the app are not handled properly.

To try to work around that issue, consider placing a small delay at the beginning of your test (sleep(1) should be enough).

So I did it and now it works:

override func setUp() {
    super.setUp()
    continueAfterFailure = false
    app = XCUIApplication()
    app.launch()
    sleep(1)
}

For UIWebView which is hittable, the tap didn't work until I've done it via coordinate:

extension XCUIElement {
    func forceTap() {
        coordinate(withNormalizedOffset: CGVector(dx:0.5, dy:0.5)).tap()
    }
}

Hope it helps someone

P.S. Also works for items that are not hittable, like labels and such.