views:

164

answers:

1

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.

+2  A: 

This might help

org.life.java
Thank you very much, and I'm sorry for late response.I read the link you game, but my problem still remains. When I use gcc 4.2(needed for iOS4), no coverage report generated.I'll read gcov's source and feed back here.
taichino
@taichino you can always upvote and select it as answer it its really
org.life.java