我一直试图让代码覆盖率适用于iPhone模拟器,并始终获得0%的覆盖率.以下是配置详细信息和我尝试过的步骤.
组态
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" 添加到"其他链接标志"UIApplicationExitsOnSuspend Info.plist中的标志设置为true结果
我生成了.gcda文件,但覆盖率始终显示为0%.
尝试了设置
将GCC更改为4.0和4.2.当我尝试将GCC更改为4.0时,我得到26个构建错误.
设置环境变量
(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 …Run Code Online (Sandbox Code Playgroud)