There seem to be a few bugs in Xcode8 that can cause this. However, I found a solution for the case where Xcode is trying to find the TEST_HOST application in the Intermediates/CodeCoverage/
folder. (I tried all other solutions with module names, etc., and this did not work for me.)
The problem itself is that Xcode is not even trying to create an application before running the tests. However , when Xcode can find the TEST_HOST in the folder that it will rebuild when the tests run. This is how we can find our way around it.
Two possible solutions:
If you don’t need to have code coverage: Go to the unit test build settings and set Enable Code Coverage Support
to No and to disable code coverage in the build setup test setup. (Change scheme, select Test on the left). If you want to run unit tests and get the TEST_HOST error message, try creating ( CMD + B ) or starting the application. Then you can run your tests without this error. Voila.
If you need code coverage: You can follow a specific workaround to populate this Intermediates/CodeCoverage/..
folder. Once the application is inside Xcode, it will be rebuilt for unit tests as it should, but you need to populate it once. Here's how you do it:
- In the application and unit test, select None for Enable Code Coverage Support.
- Then, on the General tab of the unit test goal, set the test host application to No
- Uncheck Allow Host API Validation
- Try running unit tests. Now Xcode will at least try to build. If Xcode gives a build error (sometimes Xcode complains about Cocoapods here in my experience), try creating one more time.
- Recheck "Allow Host API Testing" again in unit test target
- Try the tests again as above. Xcode must complain.
- Now install the test node in the application.
- Now the tests should pass. (Until you run clean, you will have to repeat these steps.)
I know this is annoying. But this is the only solution to the problem so far.
source share