2
votes

I have an existing iOS project with the application and unit test targets. The code coverage on running the unit tests was fine on Xcode 9.2. But I just cannot get it to run properly on Xcode 9.3

I have gone into the scheme for the unit tests and selected "Gather code coverage for ..." in the "Test" selection.

If I select "all targets" for gather code coverage option, it generates coverage for all targets other than the main application - for the embedded frameworks, for the frameworks brought in by Coocapods and also for the test files themselves

If select "some targets" and specifically select the main application target then absolutely no coverage data is generated.

I am not sure what setting is wrong in my scheme. I have also tried ot run tests from the unit test scheme as well as the main target scheme (with test running the unit test scheme), but no luck. Looking for pointers on what may be wrong.

1

1 Answers

4
votes

Turns out that the SWIFT_OPTIMIZATION_LEVEL (Optimization Level) had been changed to optimize for speed [-O] in debug configuration. I don't remember if I forgot to revert it after filling with various build settings, or something went wrong in the project migration. But changing it back No Optimization [-Onone] fixed the problem for me