Code coverage with cocoapods library - iOS Unit Test

允我心安 提交于 2019-12-01 07:07:57

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/40102012/code-coverage-with-cocoapods-library-ios-unit-test

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!