5

I'm trying to use gcov on iPhone Project and followed Apple's instruction described here, but it doesn't work.

When I build and go configured project, .gcda file is created for each object file. But no executed lines are recorded to .gcda files. (CoverStory shows all coverages are 0%)

I just added a simple class to template project as following.

@interface SomeClass : NSObject
- (void)func1:(BOOL)flag;
@end

@implementation SomeClass
- (void)func1:(BOOL)flag {
  if (flag) {
    NSLog(@"flag is YES");
  }
  else {
    NSLog(@"flag is NO");  
  }
}
@end

I allocated this class and call func1 in application:didFinishLaunchingWithOptions, and I expected that coverage of SomeClass is showed (50% or so).

I'm using OSX 10.6.4, iPhone SDK 4.0 and Xcode 3.2.3. Some more configurations are needed? Please guide.

UPDATE 2010/7/15:

I tried these hints in the link @tonclon gave me, but it didn't work yet. In the following description is what I tried.

  1. Cocoa Application compiled by GCC 4.0 In project settings of "Cocoa" Application,

    • set GCC_INSTRUMENT_PROGRAM_FLOW_ARCS to YES
    • set GCC_GENERATE_TEST_COVERAGE_FILES to YES
    • set Other Linker Flag to -lgcov
    • set C/C++ Compiler Version to 4.0

    It worked, .gcda files were generated with coverage information as expected. In iPhone project with SDK 4.0, however, I can't use same configuration because gcc 4.0 can't compile some syntax in SDK 4.0 (ex Blocks)

  2. using custom gcov library in google-tool-box Instead of setting -lgcov in Other Linker Flag, I tried custom gcov library included in google-toolbox-for-mac, but generated .gcda files shows coverage is 0%. (same result)

Can you please tell me what I should do next? Any suggestions are appreciated.

Community
  • 1
  • 1
taichino
  • 1,135
  • 1
  • 15
  • 30
  • Have you followed all hints given here: http://stackoverflow.com/questions/1385568/why-doesnt-gcov-report-any-lines-being-covered-by-my-unit-tests – tonklon Jul 12 '10 at 12:45
  • @tonclon Thank you very much for your information, I tried these hints in that link, but it didn't work yet.. I'm updating my question. Can you please tell me more hints about this issue? – taichino Jul 14 '10 at 15:22
  • Somewhat unhelpful, but gcov is no longer supported; we gave up on using it. – tc. Aug 21 '10 at 04:38
  • @tc Where do you know that from? Please give a link and consider to answer instead commenting, can't award the bounty to an comment. – tonklon Aug 23 '10 at 07:53
  • You want coverage on which language? ObjectiveC? C? – Ira Baxter Aug 24 '10 at 02:30
  • @Ira Baxter Thank you for your comment, I want to measure Objective-C's code coverage. – taichino Aug 24 '10 at 05:16
  • @taichino: Ah. I might have been help if it had been conventional C. Can't help with objective C. – Ira Baxter Aug 24 '10 at 07:33

1 Answers1

0

A couple of things:

  1. Turn off prefix headers
  2. Make sure you quit "correctly"

Please check out the gcov pages here (http://code.google.com/p/google-toolbox-for-mac/w/list) and see if they help at all. I have gcov working with Xcode 3.2.5 and iOS4.2.

dmaclach
  • 3,403
  • 1
  • 21
  • 23