Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to exclude Pods from Code Coverage in Xcode

Tags:

xcode

ios

testing

Is there a way to exclude Pods from Code Coverage?
I would like to see Code Coverage only for the code I've written.

Not that it should matter, but I'm using Xcode 8.

like image 271
Fengson Avatar asked Sep 24 '16 08:09

Fengson


People also ask

How does Xcode measure code coverage?

To measure and visualize code coverage for a project, follow these steps: Enable code coverage date gathering. To do this, go to Product › Scheme › Edit Scheme... , and select Test from the left hand side menu. Under the Info section, check the Gather coverage data box.

Where is POD file in Xcode?

The Podfile is located in the root of the Pods project. An easy way to open it is via "Open Quickly" (Shift Cmd O) typing Podfile. Show activity on this post. If it's been added to the project, you can just click on it.

What is POD file in Xcode?

The Podfile is a specification that describes the dependencies of the targets of one or more Xcode projects. The file should simply be named Podfile . All the examples in the guides are based on CocoaPods version 1.0 and onwards.


1 Answers

These steps will help:

1. add these lines to Podfile

# Disable Code Coverage for Pods projects post_install do |installer_representation|     installer_representation.pods_project.targets.each do |target|         target.build_configurations.each do |config|             config.build_settings['CLANG_ENABLE_CODE_COVERAGE'] = 'NO'         end     end end 

2. run pod install

Now you won't see pods in test coverage.

Note: It only excludes Objective-c pods but not Swift

like image 58
Tung Fam Avatar answered Oct 06 '22 00:10

Tung Fam