Code coverage with cocoapods library - iOS Unit Test
Asked Answered
B

1

3

In Xcode 7, the library for cocoapods library with exclude for the code coverage.

But In Xcode 8, the library will include for code coverage.

Can I had anyway to exclude the library in the code coverage?

Example: Install pod 'TPKeyboardAvoiding' TPKeyboardAvoidingScrollView.m is include in the code coverage.

Burnie answered 18/10, 2016 at 7:23 Comment(1)
Possible duplicate of How to exclude Pods from Code Coverage in XcodeWinn
P
3

You should disable the Code Coverage for the Targets that you don't want to be covered. If you want all of your pods to not be included in the code coverage you can add on your 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

This will disable the Code Coverage for the target of your Pods like in this image

If you now run the test with command + U

I tried with this pod in one of my project and it worked for me. I'm using Xcode Version 8.1 (8B62)

Anyway, I'm still struggling with the same issue for other pods like Cartography. There's a particular setting (which I didn't discover yet) that it seems to override the CLANG_ENABLE_CODE_COVERAGE and the tests still produces the Code Coverage for that.

Let me know if this solve your issue.

Proof answered 8/11, 2016 at 10:51 Comment(2)
Looks like if the pod is in Swift - it won't be hidden, only ObjC pods are being hiddenHawserlaid
don't forget to run pod installGeffner

© 2022 - 2024 — McMap. All rights reserved.