I had a similar issue and my mistake was trying to use UI testing code in a regular test target. Once I made a new target, starting with “iOS UI Testing Bundle” and copied the code there the error went away. Here’s the thread that pointed me in the right direction:
https://twitter.com/punksomething/status/609505357132500993
“Yeah, I was trying to use a UI test in a regular test target. Had to create a newly added UI Test target”