- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已经克服了在 iPhone 项目上设置 gcov
的所有问题,但现在我得到了以下信息:
profiling:/Users:Cannot create directory
有人对我可能做错的事情有什么建议吗?
我最初按照 Google 的说明设置 gcov,可以通过 Google 搜索“UsingCoverStory”找到该说明
更新:好吧,让我澄清一下我想做什么。我有一个 iPhone 应用程序,我试图自动测试它。我正在使用 UISpec
框架来驱动 GUI。我真正需要知道的是我的测试实际上覆盖了多少代码。我认为我已经很接近了,但我只需要了解如何正确设置环境/编译器变量以适合我的项目。
这是我迄今为止所做工作的总结。我首先复制了构建目标,指定了链接器标志和规定的其他几个选项。 (这可以使用 Google 创建的 AppleScript 自动完成。可以通过 Google 搜索“UsingCoverStory”找到说明和下载)无论如何,我已经验证了这些设置是否已正确分配。我将配置设置为“调试”,并在 3.1.3 设备上运行它。当我运行该应用程序时,它不会在调试器中显示任何特殊内容,直到我退出该应用程序。此时我收到一个错误:
profiling:/Users:Cannot create directory
profiling:/Users/forbushbl/Documents/TestApp/build/TestApp.build/Debug-iphoneos/TestApp copy.build/Objects-normal/armv6/ApplicationController.gcda:Skip
我假设 GCOV
正在尝试写出 .gcda
文件,但我不太确定如何告诉它应该将它们写入何处。我在某处读到, GCOV
尝试重现 .gcno
文件存储在我的项目文件夹中的目录结构,这是有意义的,因为上面的目录是 >.gcno
文件位于我的计算机上。然而,这是一个问题,因为 iPhone 上不存在该结构,设备也无法创建该结构。
我发现另一个人也有同样的问题,他们说他们必须设置一个环境变量。 How to set up gcov for code coverage analysis in iPhone SDK?
GCOV
文档说明如下:
For example, if the object file
/user/build/foo.o
was built with-fprofile-arcs
, the final executable will try to create the data file/user/build/foo.gcda
when running on the target system. This will fail if the corresponding directory does not exist and it is unable to create it. This can be overcome by, for example, setting the environment as `GCOV_PREFIX=/target/run' and `GCOV_PREFIX_STRIP=1'. Such a setting will name the data file/target/run/build/foo.gcda
.
我的问题是,如何在 iPhone 上设置这些环境变量?我应该在构建配置中还是在实际代码中执行此操作?
最佳答案
您应该在项目的 main.m 文件中使用 setenv 设置这些变量:
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.
注意:确保上面的代码位于:
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
int retVal = UIApplicationMain(argc, argv, nil, nil);
[pool release];
return retVal;
关于iphone - 如何在 iPhone 上为 gcov 设置环境变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3049910/
我是一名优秀的程序员,十分优秀!