组态
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
结果
设置尝试了
>将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 directoryconst 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设置为None(-O0),并取消选中预编译的前缀头文件标志.
解决方法 感谢stackoverfow和 CubicleMuses的所有信息我有代码覆盖工作为模拟器和设备!以下是为我工作的步骤和配置:
配置:Xcode 4!
XCode项目设置
构建设置
>其他linker标志:添加“-lgcov”
> GCC_GENERATE_TEST_COVERAGE_fileS:设置
到YES
> GCC_INSTRUMENT_PROGRAM_FLOW_ARCS:设置
到YES
> C/C++编译器版本:GCC
4.2(如果你在XCode 4)iOS部署目标:4.2
>预编译前缀标题:NO
的Info.pList
>设置UIApplicationExitsOnSuspend标志
在您的Info.pList中为YES
以上步骤对于模拟器和设备是相同的,但是我们还有一些额外的工作要使其在设备上工作.
Main.m:将以下代码复制粘贴到main.m
const char *prefix = "GCOV_PREFIX";const char *prefixValue = [[NSHomeDirectory() stringByAppendingPathComponent:@"documents"] cStringUsingEnCoding:NSASCIIStringEnCoding]; // This gets the filepath to the app's documents directoryconst char *prefixStrip = "GCOV_PREFIX_STRIP";const char *prefixStripValue = "1";setenv(prefix,and use the filepath that we just declared.
注意:确保以上代码在之前:
NSautoreleasePool * pool = [[NSautoreleasePool alloc] init];int retVal = UIApplicationMain(argc,argv,nil,nil);[pool release]; return retVal;
为什么我们设置上述覆盖变量?
http://gcc.gnu.org/onlinedocs/gcc/Cross_002dprofiling.html
如何获取.gcda文件?
使用Xcode中的管理器从设备下载应用程序的包,以将.gcda文件从documents目录中取出.
注意:我无法使用相同设置的Xcode 3.2.5获得代码覆盖.但Xcode 4是蛋糕步行:-)
总结以上是内存溢出为你收集整理的objective-c – 代码覆盖率不显示使用Xcode gcov的结果全部内容,希望文章能够帮你解决objective-c – 代码覆盖率不显示使用Xcode gcov的结果所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)