10

I'm using gcovr to generate code coverage for cobertura. Everything was working fine with xcode 4.6. Now I updated to xcode5 and everything I get is 0% coverage...

my setup:

  • gcovr 3.0
  • Xcode 5 (Apple LLVM 5)
  • 'Generate Test Coverage Files' is set to YES
  • 'Instrument Program Flow' is set to YES

and to command I use:

gcovr -r . --object-directory Build/Intermediates/myApp.build/Debug-iphonesimulator/myApp.build/Objects-normal/i386 --exclude '.*Tests.*' --exclude '.*KiwiUnitTest' --exclude '.*main.*' --xml > reports/coverage.xml

is someone having the same issue or better, have a solution? :)

Alex
  • 142
  • 2
  • 9
  • 3
    Possible duplicate of [Xcode5 Code Coverage (from cmd-line for CI builds)](http://stackoverflow.com/questions/18394655/xcode5-code-coverage-from-cmd-line-for-ci-builds) – Gardner Bickford Oct 15 '13 at 18:29
  • No, this is NOT a dupe. The suggestion by @GardnerBickford relates to generating the .gcno/.gcda files. THIS question relates to the use (and malfunction) of gcovr. – Rayfleck Dec 24 '13 at 15:03
  • @Rayfleck please read this question again as well as the answer [ Xcode5 Code Coverage (from cmd-line for CI builds)](http://stackoverflow.com/questions/18394655/xcode5-code-coverage-from-cmd-line-for-ci-builds) This reason why gcovr is not working after upgrading to Xcode 5 is because the Xcode 5 compiler does not flush the gcno/gcda files out to disk. **Without these files gcovr will report no coverage.** – Gardner Bickford Dec 27 '13 at 22:35
  • @GardnerBickford - ah, yes, I stand corrected. Thanks. I voted to close this post. – Rayfleck Dec 28 '13 at 16:07
  • Xcode 5.1 fix this issue and adds llvm-cov – ıɾuǝʞ Mar 12 '14 at 08:28
  • thy you guys. I didn't had time to try it now. I will test it as soon as possible and post what worked for me. – Alex Mar 25 '14 at 10:05

2 Answers2

3

And now it works again... :)

as @kenji said, Xcode 5.1 solved the problem. thx btw

here is my working environment and configuration for the one who are interested

  • Xcode 5.1.1 (from the AppStore)
  • gcovr 3.1-prerelease (installed with easy_install)

and in my project under 'Build Settings' I set the following:

  • 'Generate Test Coverage Files' is set to YES
  • 'Instrument Program Flow' is set to YES

after I run the tests, I execute the following command: (happens with jenkins)

gcovr -r . --object-directory Build/Intermediates/MyProj.build/Debug-iphonesimulator/KiwiUnitTest.build/Objects-normal/i386 --exclude '.*Tests.*' --exclude '.*KiwiUnitTest' --exclude '.*main.*' --xml > reports/coverage.xml

done.

sorry guys for making you wait for an answer and thank you everyone for your help.

Community
  • 1
  • 1
Alex
  • 142
  • 2
  • 9
0

At first make sure that your .gcda and .gcno files are created!

(Check: ~/Library/Developer/Xcode/DerivedData/{YOUR-PROJECT-NAME}/Build/Intermediates/{YOUR-PROJECT-NAME}.build/Debug-iphonesimulator/{YOUR-PROJECT-NAME}.build/Objects-normal/i386 )

If they have been successfully created you need to do the following: (If not check the comments under your question)

  1. copy the all the files from the folder i386 (full path as described above) into you workspace where your .h and .m files are.

  2. run terminal and change you parent working directory to your workspace

     cd [YOUR WORKSPACE PATH]
    
  3. run gcovr

     gcovr -r . --xml  > reports/coverage.xml
    

If you are using jenkins (which i assume) this will be your further steps: Generating gcda files to view the code-coverage from XCTests in IOS with Jenkins

Let me know if you still have questions!

Community
  • 1
  • 1
hirschfl
  • 46
  • 3
  • It does seem that the latest version of gcovr (v3.2) won't process any files if you define the --object-directory. Only by copying your .gcno and .gcna files to the path defined by the -r parameter will it work. https://github.com/gcovr/gcovr/issues/61 – Ari Braginsky Feb 16 '15 at 06:28