配置:
Xcode 3.2.5/iOS 4.1和iOS 4.2/Mac 10.6/GCC 4.2应用程序UICatalog
参考文献:
http://www.cubiclemuses.com/cm/articles/2009/05/14/coverstory-on-the-iphone/
http://developer.apple.com/library/mac/#qa/qa2007/qa1514.html
步骤
- 启用“生成测试覆盖文件”
- 启用“仪器程序流程”
- 将“
-lgcov
”添加到“其他链接器标志”中 - 在Info.plist中将
UIApplicationExitsOnSuspend
标志设置为true
结果
我已经生成了.gcda文件,但覆盖率始终显示为0%。
尝试的设置
Changing GCC to 4.0 and 4.2. When I try to change the GCC to 4.0 I get 26 build errors.
Set environment variables
(const char *prefix = "GCOV_PREFIX"; const char *prefixValue = [[NSHomeDirectory() stringByAppendingPathComponent:@"Documents"] cStringUsingEncoding:NSASCIIStringEncoding]; // This gets the filepath to the app's Documents directory const char *prefixStrip = "GCOV_PREFIX_STRIP"; const char *prefixStripValue = "1"; setenv(prefix, prefixValue, 1); // This sets an environment variable which tells gcov where to put the .gcda files. setenv(prefixStrip, prefixStripValue, 1); // This tells gcov to strip the default prefix, and use the filepath that we just declared.)
GCC Optimization set to None (-O0) and unchecked the precompiled prefix header file flag.