jonreid / xcodecoverage Goto Github PK
View Code? Open in Web Editor NEWCode coverage for Xcode projects (Objective-C only)
License: MIT License
Code coverage for Xcode projects (Objective-C only)
License: MIT License
First of all, thanks for this script.
I tested this script with a sample project (here the source: https://github.com/ignazioc/SampleCodeCoverage)
and the report shows 0% coverage on the unique sample class inside the project.
But when i use cover story on the same project it shows 100% coverage.
Unable to see coverage report in XCode 12.4 with new build system. Please see below error
15:21:19 + mkdir -p ../../build/reports/coverage_Report
15:21:19 + echo 'XcodeCoverage report generating..'
15:21:19 XcodeCoverage report generating..
15:21:19 + XcodeCoverage/getcov -o ../../build/reports/coverage_Report
15:21:19 output_dir = ../../build/reports/coverage_Report
15:21:19 /opt/jenkins/workspace/iOS_PullRequest_Unit/build/reports/coverage_Report /opt/jenkins/workspace/iOS_PullRequest_Unit/src/elektra
15:21:19 /opt/jenkins/workspace/iOS_PullRequest_Unit/src/elektra
15:21:19 Capturing coverage data from /Users/jenkins/Library/Developer/Xcode/DerivedData/elektra-dqgphexvdqtbmicihhexfohtaasc/Build/Intermediates.noindex/elektra.build/Debug_Fluke-iphonesimulator/elektra.build/Objects-normal/undefined_arch
15:21:19 Found LLVM gcov version 12.0.0, which emulates gcov version 4.2.0
15:21:19 geninfo: ERROR: cannot read /Users/jenkins/Library/Developer/Xcode/DerivedData/elektra-dqgphexvdqtbmicihhexfohtaasc/Build/Intermediates.noindex/elektra.build/Debug_Fluke-iphonesimulator/elektra.build/Objects-normal/undefined_arch!
15:21:19 lcov: ERROR: cannot read file Coverage.info!
15:21:19 Reading tracefile Coverage.info
I'm getting the following error when gathering coverage with getcov:
Capturing coverage data from .build/Release-iphonesimulator/Supervisor-cal.build/Objects-normal/i386
Found gcov version: 4.2.1
Found 180 data files in .build/Release-iphonesimulator/Supervisor-cal.build/Objects-normal/i386
Processing i386/AboutViewController.gcda
Processing i386/Agent.gcda
Processing i386/AgentStatsGridController.gcda
Processing i386/AppDelegate.gcda
Stack dump:
0. Program arguments: /usr/bin/gcov .build/Release-iphonesimulator/Supervisor-cal.build/Objects-normal/i386/AppDelegate.gcda -o .build/Release-iphonesimulator/Supervisor-cal.build/Objects-normal/i386
I don't know if it issue of XcodeCoverage or Xcode itself.
I have target with name 'app develop'. If I run test I don't see .gcda files generated. If I run tests for 'app' target everything works.
Except of renaming target are there solutions?
How to set the specified files to whitelist?
i want to add some files to whitelist, and only Check these files。
our project is very big. and contain so many sdks, usually one feature we only chang A few files, i only want to check that files. don't care others files. What should I do?
thanks, waitting for your replay!
Hi,
After building the app, getting the gcno files and launching the app, I manually operated on the app and then closed the simulator. Then I got the hint that where I want to generate the coverage files and I clicked yes. After that, I manually ran the getcov file but I got the error msg "GCov_Build-iphoneos/lcov/index.html does not exist".
Which did I miss?
xcode 11.3.1
Coverage data includes Apple's SDKs
Unable to see coverage report in XCode 11.6 with new build system. Please see below error
11:00:18 + mkdir -p ../../build/reports/coverage_Report
11:00:18 + echo 'XcodeCoverage report generating..'
11:00:18 XcodeCoverage report generating..
11:00:18 + XcodeCoverage/getcov -o ../../build/reports/coverage_Report
11:00:18 output_dir = ../../build/reports/coverage_Report
11:00:18 /opt/jenkins/workspace/iOS_PullRequest_Unit/build/reports/coverage_Report /opt/jenkins/workspace/iOS_PullRequest_Unit/src/elektra
11:00:18 /opt/jenkins/workspace/iOS_PullRequest_Unit/src/elektra
11:00:18 Capturing coverage data from /Users/jenkins/Library/Developer/Xcode/DerivedData/elektra-dqgphexvdqtbmicihhexfohtaasc/Build/Intermediates.noindex/elektra.build/Debug_Fluke-iphonesimulator/elektra.build/Objects-normal/undefined_arch
11:00:18 Found LLVM gcov version 11.0.3, which emulates gcov version 4.2.0
11:00:18 geninfo: ERROR: cannot read /Users/jenkins/Library/Developer/Xcode/DerivedData/elektra-dqgphexvdqtbmicihhexfohtaasc/Build/Intermediates.noindex/elektra.build/Debug_Fluke-iphonesimulator/elektra.build/Objects-normal/undefined_arch!
11:00:18 lcov: ERROR: cannot read file Coverage.info!
11:00:18 Reading tracefile Coverage.info
Hello Jon,
It would be helpful if the Pod allowed you to install the latest lcov release, but the last available tag is stuck at lcov 1.11. Could you retag and update and publish the podspec?
HI,
I am generating Code coverage using terminal after test cases succeed by running run_code_coverage_post.sh. It works fine with Xcode 10.4.1, but on Xcode 10 beta it's giving below errors: Please help me in resolving these this issue.
geninfo: ERROR: cannot read /Users/Abhishek/Library/Developer/Xcode/DerivedData/TRADFRI-fuzpwmjhzkdzrbbfjbnlwglkcolz/Build/Intermediates.noindex/TRADFRI_LIB.build/Debug-iphonesimulator/TRADFRI_LIBTests.build/Objects-normal/undefined_arch!
Reading tracefile Coverage.info
lcov: ERROR: cannot read file Coverage.info!
Reading tracefile Coverage.info
lcov: ERROR: cannot read file Coverage.info!
cat: /Users/Abhishek/Documents/Usman/LSProject/tradfri-ios/External/FREKVENS_LIB/.xcodecoverageignore: No such file or directory
Reading tracefile Coverage.info
lcov: ERROR: cannot read file Coverage.info!
Reading data file Coverage.info
genhtml: ERROR: cannot read file Coverage.info!
The file /Users/Abhishek/Library/Developer/Xcode/DerivedData/TRADFRI-fuzpwmjhzkdzrbbfjbnlwglkcolz/Build/Products/Debug-iphonesimulator/lcov/index.html does not exist.
Thanks and Regards,
Usman Ansari
Hi,
I'm able to export a nice report for test running on simulator.
But when trying with the actual device, I always get the following errors:
"Reading tracefile Coverage.info
lcov: ERROR: no valid records found in tracefile Coverage.info"
Any suggestion? Thank you
I'm able to successfully run and build my project using a standard installation of XcodeCoverage on a local instance on my machine.
However, our TeamCity CI Server (Mac Mini OSX 10.10 with Xcode) is unable to successfully execute the exportenv.sh script. This results in a null env.sh which then causes some additional libraries to fail (fabric io specifically) thus causing compile errors.
There really isn't much of an error being posted to console output either, it simply says
"[13:33:47]Step 2/6: export env.sh (Command Line)
[13:33:47][Step 2/6] Starting: /Library/TeamCity/buildAgent/temp/agentTmp/custom_script9004978931224840444
[13:33:47][Step 2/6] in directory: /Library/TeamCity/buildAgent/work/c611c1ea3bea1202
[13:33:47][Step 2/6] Process exited with code 1
[13:33:47][Step 2/6] Step export env.sh (Command Line) failed"
I've reviewed the actual script and I don't see any errors or mistakes, it also hasn't been modified.
Is there anything that I should be calling/running before calling exportenv.sh I know there are a handful of build scripts in there. Any help is very much appreciated!
Hi, jonreid,I found the XcodeCoverage cannot work for Xcode 8GM
I'm getting the following error when trying to run XcodeCoverage
[ProjectName]/Libraries/XcodeCoverage/exportenv.sh: line 7: XcodeCoverage/env.sh: No such file or directory
My directory structure is as follows
I have used the following script command "[ProjectName]/Libraries/XcodeCoverage/exportenv.sh"
I am using Xcode 4.6.
I have not added any of the files to the actual project just placed them within the folder. Either way it can see the script, just can't access the env.sh file
How to set IGNORED
Hi Jon,
I hope you're doing well. I only see objective-c files in my test coverage report. Does this project support Swift ?
Thanks,
Alex
I just noticed an issue when trying to run my tests against a 64bit simulator e.g. an iPhone 6 simulator.
Then the script always puts i386
as CURRENT_ARCH
into the env.sh
file.
Might this be an issue I'm having with my build settings or does anyone know another way to fix this? Thanks!
Hi All,
Could you please help in filtering files in code coverage , as explained in documentation created a file.xcodecoverageignore, but there is no luck in filtering, so please help .
Thanks
Praveen kanike
Can we show branch coverage or decision coverage in html format?
Thanks
myfile.gcda: cannot open: No such file or directory
I installed XcodeCoverage to my project like descriped in README.md. I tried pods and standard installation and had always the same effect:
I already asked Google but didn't get an answer that worked. I also tried the __gcov_flush() function, but no effect neither.
I use Xcode6, iOS simulator 8.3 and 8.4.
Any ideas?
For some reason the @implementation line for this one class is showing as not being covered.
looks like the post build script is not running
also the environment variables has changed
It the path containing XcodeCoverage contains spaces, cleancov and getcov truncate the path at the first space. For example, if XcodeCoverage is located at /Users/Foo/Bar Baz/, the aforesaid scripts return an error stating /Users/Foo/Bar: No such file or directory.
What's the difference between the coverage files (.gcda and .gcno) in these two directories:
DerivedData/<app>/Build/Intermediates/<app>.build/Debug-iphonesimulator/**<app>Tests.build**/Objects-normal/i386/
vs
DerivedData/<app>/Build/Intermediates/<app>.build/Debug-iphonesimulator/**<app>.build**/Objects-normal/i386/
I see that your script reports the coverage numbers from the 2nd directory. What's the difference? Why did you choose one over the other? I have vastly different coverage metrics when I compare what's reported from either of those.
Hi, I want to dump the gcda file without line counter (line hit result is either 0 or 1), I known the "gcda" file save this info. How can I do?
geninfo: Can't exec "/Volumes/Data": No such file or directory at /Volumes/Data Backup/Code covarage Demo/covarageDemo/Pods/XcodeCoverage/lcov-1.13/bin/geninfo line 1965.
geninfo: ERROR: cannot retrieve gcov version!
Reading tracefile Coverage.info
lcov: ERROR: cannot read file Coverage.info!
Reading tracefile Coverage.info
lcov: ERROR: cannot read file Coverage.info!
cat: /Volumes/Data Backup/Code covarage Demo/covarageDemo/.xcodecoverageignore: No such file or directory
Reading tracefile Coverage.info
lcov: ERROR: cannot read file Coverage.info!
Reading data file Coverage.info
genhtml: ERROR: cannot read file Coverage.info!
logout
When running on XCode 7 I get:
lcov: ERROR: no valid records found in tracefile Coverage.info
Reading data file Coverage.info
genhtml: ERROR: no valid records found in tracefile Coverage.info
Coverage report is in lcov folder
brew install lcov
gets me lcov and genhtml
It would be nice XcodeCoverage scripts can find lcov on PATH, so
I won't need to fork and customize paths.
Hi,
I really liked your tool to get html version coverage report, but I've been getting Unexpected number of edges and Unexpected number of functions errors when I tried to generate report for my unit test, also the xcodecoverageignore file is not working as expected, an sample is ${SRCROOT}/../../../../android/sdk/src/main/jni/source/sqlite3.c.
Please advise thanks.
I'd rather not add this to my project folder. Is there a way to put this into my path, and call it from Xcode?
To get coverage files for Swift code seems to be impossible now according to this. http://www.openradar.me/17450338
Code Coverage is commonly used with tests in Xcode. I would like to use it for manually executed app. Can I do it, possibly with third-party tools?
For example: I build and launch the app on device, perform some actions with it and then look at code coverage results.
before Xcode7. The way we achieved this was, to set the "Instrument Program Flow" and "Generate Test Coverage files" flags to Yes, on your project, and later add a "flush" code somewhere inside you application, to write the coverage data files. This "flushing" part actually writes the coverage data files, which can be used later by other tools such as gcovr or lcov, to get your coverage data. Once you interact with the app, either manually or through automated tests, the coverage data gets written.
However, with Xcode7, looks like the coverage data is limited to only Xcode unit tests. I am still trying to figure out, if there is any way to gather the coverage data, by interacting with the application manually, or through automated tests.
Please let me know if you find something useful.
Hi
After updating to v1.4 there is no branch coverage option i am getting only functions and lines.
I'm having some issues running ./getcov after switching to Xcode 5.1 (I've replaced any calls to my app name with [App] and its test suite to [AppTests]):
Ellens-MacBook-Pro-2:XcodeCoverage ellenshapiro$ ./getcov ~/Library/Developer/Xcode/DerivedData/[App]-gsolxombszraeughodjqqewnlxgd/Build/Products/Debug-iphonesimulator ~/Desktop/[App]/iOS_SDK/Project/XcodeCoverage ~/Desktop/[App]/iOS_SDK/Project/XcodeCoverage Capturing coverage data from /Users/ellenshapiro/Library/Developer/Xcode/DerivedData/[App]-gsolxombszraeughodjqqewnlxgd/Build/Intermediates/[App].build/Debug-iphonesimulator/[AppTests].build/Objects-normal/i386 gcov: Unknown command line argument '-v'. Try: '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/gcov -help' gcov: Did you mean '-a'? gcov: Not enough positional command line arguments specified! Must specify at least 1 positional arguments: See: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/gcov -help geninfo: Use of uninitialized value $version_string in pattern match (m//) at /Users/ellenshapiro/Desktop/[App]/iOS_SDK/Project/XcodeCoverage/lcov-1.10/bin/geninfo line 1874. geninfo: Use of uninitialized value $gcov_version_string in pattern match (m//) at /Users/ellenshapiro/Desktop/[App]/iOS_SDK/Project/XcodeCoverage/lcov-1.10/bin/geninfo line 3622. geninfo: Use of uninitialized value $gcov_version_string in pattern match (m//) at /Users/ellenshapiro/Desktop/[App]/iOS_SDK/Project/XcodeCoverage/lcov-1.10/bin/geninfo line 3622. Scanning /Users/ellenshapiro/Library/Developer/Xcode/DerivedData/[App]-gsolxombszraeughodjqqewnlxgd/Build/Intermediates/[App].build/Debug-iphonesimulator/[AppTests].build/Objects-normal/i386 for .da files ... geninfo: ERROR: no .da files found in /Users/ellenshapiro/Library/Developer/Xcode/DerivedData/[App]-gsolxombszraeughodjqqewnlxgd/Build/Intermediates/[App].build/Debug-iphonesimulator/[AppTests].build/Objects-normal/i386! Reading tracefile Coverage.info lcov: ERROR: no valid records found in tracefile Coverage.info Reading tracefile Coverage.info lcov: ERROR: no valid records found in tracefile Coverage.info Reading data file Coverage.info genhtml: ERROR: no valid records found in tracefile Coverage.info The file /Users/ellenshapiro/Library/Developer/Xcode/DerivedData/[App]-gsolxombszraeughodjqqewnlxgd/Build/Products/Debug-iphonesimulator/lcov/index.html does not exist.
I was able to find this Stack Overflow post, which appears to have some information like that -v is now deprecated, but it seems from that post like Xcode 5.1 has opened up a rather large can of worms with this change.
Any thoughts on how to make this script play nice with Xcode 5.1?
First off - I just ran through your setup and have to say that this is phenomenal. By far, the most easiest and quickest setup for measuring code coverage of iOS projects. I was nervous when I found an outdated blog post referencing this project, but then when I came to GitHub and saw you are actively maintaining it, I was pumped. Thank you
How can I modify this script to generate an XML report that may be consumed by Cobertura in order to better display the coverage stats in Jenkins?
I'd like to generate coverage report for a sandboxed OS X file. This is a little tricky, because the running application cannot write covering coverage data to it's build directory.
I followed the instructions at https://developer.apple.com/library/ios/qa/qa1514/_index.html for sandboxed applications.
The .gcda files are now located in the sandboxed application's Document directory within its sandbox container. e.g. ~/Library/Containers/<bundle_id>/Data/Documents/Build/Intermediates//........
The .o file and .gcno files are somewhere in Xcode's derived data directory. Any ideas how to handle this situation?
Hi, I have downloaded your project and try it.
But the first time I try to run the ./getcov there is this error "envcov.sh: line 7: env.sh: No such file or directory".
I hope you could help me.
Thanks in advance.
where i can but my excluding paths there no files with this extension .xcodecoverageignore
to add ${SRCROOT}/TestedProject/Machine Files/*
While source/line coverage is still measured, functions coverage is not. The resultant report shows 0/0 functions coverage for every source file.
Since SDK 9 I am unable to use XcodeCoverage.
I cannot turn on INSTRUMENT_PROGRAM_FLOW to generate the GCOV files, as it causes my test run to fail. Lots of "cannot merge previous GCDA file: corrupt arc tag" entries in the console, and it then crashes in main.m showing BAD_ACCESS on the line calling UIApplicationMain.
I cannot turn INSTRUMENT_PROGRAM_FLOW on for the main target, but without it, I cannot generate GCDA files.
Is there a way to fix this, or do we need to wait till XcodeCoverage supports LLVM-COV profdata?
http://ltp.sourceforge.net/coverage/lcov/changes.php
I have upgraded with brew this morning and changed the LCOV base path in the XcodeCoverage's .sh file to /usr/local/bin to use that... it seems to work ok.
We could upgrade the bundled version or rely on brew in the future, what do you think?
lcov: ERROR: no valid records found in tracefile Coverage.info
Reading tracefile Coverage.info
lcov: ERROR: no valid records found in tracefile Coverage.info
Reading tracefile Coverage.info
lcov: ERROR: no valid records found in tracefile Coverage.info
Reading tracefile Coverage.info
lcov: ERROR: no valid records found in tracefile Coverage.info
Reading tracefile Coverage.info
lcov: ERROR: no valid records found in tracefile Coverage.info
Reading data file Coverage.info
genhtml: ERROR: no valid records found in tracefile Coverage.info
Can there be an input which will enable the branch coverage too?
With the current state, had to change in getcov and lcov files to generate the branch coverage.
HI Jon,
Background : We are using your XcodeCoverage report to generate html reports for our project which has a mix of ObjC and Swift Classes. ObjC works perfectly but XcodeCoverage report misses coverage for all the Swift files.
I saw your comment about no support for Swift here. Any Plans for doing it in future? Can you please add support for Swift files coverage.
Thanks.
I have 5408 files in my project and it shows only 4.
geninfo: ERROR: GCOV failed for (build_artifacts)/(class_that_errored).gcda!
Here is detailed description of problem http://stackoverflow.com/questions/22343725/xcode-5-1-unit-test-coverage-analysis-fails-on-files-using-blocks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.