Code coverage in Xcode

Xcode has added native support for the measurement of the code coverage of tests with version 7. To enable it, select Edit Scheme... in the scheme selector in Xcode:

In the following pop-up window, select the Test phase and check Gather coverage data:

That is all! If you have tried to add the gathering of code coverage in Xcode 6, you will most probably be impressed by how easy this is in Xcode 9. Close the window, and run all the tests to measure the code coverage.

After the tests have finished, select the Report Navigator, ...

Get Test-Driven iOS Development with Swift 4 - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.