Run tests with code coverage enabled

Use the scheme editor to enable code coverage that provides statistics about your source code in test reports.

Enable code coverage

  1. In the main window, choose Edit Scheme from the scheme menu in the toolbar.

  2. In the left column, select the Test scheme action, then click Info on the right.

  3. Select the “Code Coverage” checkbox.

  4. Click Close.

Select some code coverage targets

Optionally, choose to include just some targets in the report.

  1. From the “Gather coverage for” pop-up menu, choose “some targets.”

  2. In the table that appears below, click the Add button (+).

  3. In the sheet, select the targets (use Command-click to select multiple targets), then click Add.

  4. Click Close.

You can use the xccov command-line tool to process the contents of Xcode coverage reports. To learn more, enter man xccov in Terminal.

See alsoContinuous integration using Xcode ServerConfigure schemes