[英]How can i calculate code coverage of a static library in XCode 5 using a project that links to this static library?
I have an Xcode5 project that builds a static library as its product. 我有一个Xcode5项目,它构建了一个静态库作为其产品。 While building this library i had turned on the Code coverage settings ie " Generate Test Coverage files" and " Instrument Program Flow" .
在构建此库时,我打开了代码覆盖率设置,即“ 生成测试覆盖率文件”和“仪器程序流程” 。 As a result, when library was built, gcno files were created for all the files correspondingly in the same directory.
因此,在构建库时,为相应目录中的所有文件创建了gcno文件。
And in order to calculate its code coverage i have another project which links to this library and creates an executable. 并且为了计算它的代码覆盖率,我有另一个项目链接到这个库并创建一个可执行文件。 This project was also built with " Generate Test Coverage files" and " Instrument Program Flow" as YES.
该项目还使用“ 生成测试覆盖率文件”和“仪器程序流程”构建为YES。
Now, upon executing this product, only the gcda files for the files in the project of my test executable are generated. 现在,在执行此产品时,仅生成我的测试可执行文件的项目中的文件的gcda文件。
How can i generate the gcda files for the static library that was linked into my project while building it. 如何为构建它时链接到我的项目的静态库生成gcda文件。
You can do it now with Xcode 7.3. 你现在可以用Xcode 7.3做到这一点。
Put the library project and the test project into the same workspace and configure the test project to link to the product of the library project. 将库项目和测试项目放在同一工作区中,并将测试项目配置为链接到库项目的产品。 Turn on "Gather Code Coverage" in both the framework scheme in the library project and the test scheme in the test project.
在库项目的框架方案和测试项目中的测试方案中打开“收集代码覆盖率”。 After that you'll be able to see the code coverage for the library in the coverage tab in Xcode.
之后,您将能够在Xcode的coverage选项卡中看到该库的代码覆盖率。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.