在 Xcode 5 中运行代码覆盖率时出现数十个“profiling:invalid arc tag”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22519530/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Dozens of "profiling:invalid arc tag" when running code coverage in Xcode 5
提问by jasonjwwilliams
When running my Test target with code coverage enabled in Xcode 5, I get dozens of the following message in the build output:
在 Xcode 5 中启用代码覆盖率的情况下运行我的测试目标时,我在构建输出中收到许多以下消息:
profiling:invalid arc tag (0x...)
It doesn't seem to affect the tests, as they complete successfully, and also the GCDA coverage files are generated as expected.
它似乎不会影响测试,因为它们成功完成,并且 GCDA 覆盖文件也按预期生成。
Any idea what the message means, or how to suppress the messages/fix the issue, because they clutter up the build output and make it hard to find the test case results.
知道消息是什么意思,或者如何抑制消息/解决问题,因为它们使构建输出变得混乱并且很难找到测试用例结果。
回答by jstevenco
Most likely this is a result of the build tools failing to merge current results into the existing .gcda coverage files. As Dave Meehan points out here, there is a brute force way of dealing with this by cleaning the product build folder, but a less hard core approach is to delete the .gcda files from targets generating them (for me, just the test target) as part of the build process. Dave includes a sample script to be included as a build phase -- or, at the project root by hand:
这很可能是由于构建工具未能将当前结果合并到现有的 .gcda 覆盖文件中所致。正如Dave Meehan 在这里指出的那样,有一种通过清理产品构建文件夹来解决这个问题的蛮力方法,但一个不太硬的核心方法是从生成它们的目标中删除 .gcda 文件(对我来说,只是测试目标)作为构建过程的一部分。Dave 包含一个示例脚本,作为构建阶段包含在内——或者,手动在项目根目录中:
find . -name "*.gcda" -print0 | xargs -0 rm
回答by skensell
For the Xcode 7 users out there, you might have been wondering why your Unit Tests crash after receiving messages like this. The solution I found was that you need to make sure that all possible targets involved in your build flow (including all libraries) should have these two build settings set to NO:
对于 Xcode 7 用户,您可能想知道为什么您的单元测试在收到这样的消息后会崩溃。我发现的解决方案是,您需要确保构建流程中涉及的所有可能目标(包括所有库)都应将这两个构建设置设置为 NO:
GCC_GENERATE_TEST_COVERAGE_FILES = NO;
GCC_INSTRUMENT_PROGRAM_FLOW_ARCS = NO;
If you search for the "Code Generation" section in the build settings you will find these as "Generate Test Coverage Files" and "Instrument Program Flow".
如果您在构建设置中搜索“代码生成”部分,您会发现它们是“生成测试覆盖文件”和“仪器程序流程”。
For further reference see https://developer.apple.com/library/ios/qa/qa1514/_index.html
如需进一步参考,请参阅https://developer.apple.com/library/ios/qa/qa1514/_index.html
回答by A.J
Old question, but now Xcode 7 GM is out, and this behavior hasn't changed, I took a deeper look. The issue, I believe is that code coverage of the test app target is conflicting with code coverage of the main target.
老问题,但现在 Xcode 7 GM 出来了,这种行为没有改变,我深入研究了一下。我认为问题在于测试应用程序目标的代码覆盖率与主要目标的代码覆盖率相冲突。
Assuming you don't actually care about code coverage of your test target these settings stop the errors for me, with no need for extra scripts or deleting files:
假设您实际上并不关心测试目标的代码覆盖率,这些设置会为我停止错误,无需额外的脚本或删除文件:
In your main target (be it a framework, or an app) set:
在您的主要目标(无论是框架还是应用程序)集中:
Enable Code Coverage Support to YES
Generage Legacy Test Coverage Files to YES
Instrument Program Flow to YES
For my purposes I only did this for Debug builds, but your needs may vary.
出于我的目的,我仅针对 Debug 版本执行此操作,但您的需求可能会有所不同。
Then in your Tests target set:
然后在您的测试目标集中:
Enable Code Coverage Support to NO
Generage Legacy Test Coverage Files to NO
Instrument Program Flow to NO
This has resolved the error messages, and still allowed the code coverage files to be created appropriately.
这已经解决了错误消息,并且仍然允许适当地创建代码覆盖率文件。
Again, the question is old, but as the error still is issued in XCode 7, I found this solution works better than deleting files with special scripts.
同样,这个问题很老,但由于错误仍然在 XCode 7 中出现,我发现这个解决方案比删除带有特殊脚本的文件更有效。
回答by xthule
I'm having the same issue. In my appDelegate
under applicationWillTerminate:
I have the __gcov_flush();
. Commenting this out removes the invalid arc tag
messages in my build output.
我有同样的问题。在我的appDelegate
下applicationWillTerminate:
我有__gcov_flush();
. 将其注释掉会删除invalid arc tag
我的构建输出中的消息。
I'm doing further research to figure out why this happens. I know that if I completely clean my project and delete the DerivedData
directory these messages will stop for a few runs of my tests.
我正在做进一步的研究来弄清楚为什么会发生这种情况。我知道如果我完全清理我的项目并删除DerivedData
目录,这些消息将停止运行几次我的测试。
EDIT:I seemed to have fixed this for me. In my appDelegate I had the following:
编辑:我似乎已经为我解决了这个问题。在我的 appDelegate 中,我有以下内容:
#ifdef DEBUG
+ (void)initialize {
[[NSUserDefaults standardUserDefaults] setValue:@"XCTestLog,GcovTestObserver"
forKey:@"XCTestObserverClass"];
[super initialize];
}
#endif
I spelled GcovTestObserver
wrong, and after fixing this the messages stopped. Make sure you also have a subclass of XCTestObserver
in your Test target overriding stopObserving
with the following:
我拼错GcovTestObserver
了,在解决这个问题后,消息停止了。确保您XCTestObserver
的测试目标中还有一个覆盖stopObserving
以下内容的子类:
- (void) stopObserving
{
[super stopObserving];
UIApplication* application = [UIApplication sharedApplication];
[application.delegate applicationWillTerminate:application];
}
回答by adib
You might want to clear out allderived data folders. Especially if you upgrade Xcode or use more than one Xcode versions.
您可能想要清除所有派生数据文件夹。特别是当您升级 Xcode 或使用多个 Xcode 版本时。
At one time I've experienced this just after I upgraded Xcode from 6.2 to 6.3 in our integration server and we've seen these messages in the logs as well as missing classes in the coverage report generated by frankencover.it. Removing the DerivedData
folders inside the integration server fixes it.
有一次,我在我们的集成服务器中将 Xcode 从 6.2 升级到 6.3 后就遇到过这种情况,我们在日志中看到了这些消息,并且在frankencover.it生成的覆盖率报告中看到了缺失的类。删除DerivedData
集成服务器内的文件夹可以修复它。
find /Library/Developer/XcodeServer -name DerivedData -print0 | xargs -0 rm -rf
回答by apphipster
I have spent some time trying to figure out how to get rid of those ugly and annoying messages:
我花了一些时间试图弄清楚如何摆脱那些丑陋和烦人的消息:
profiling: /Users/appfactory/Desktop/WORK/App/trunk/ObjectiveC.gcda: cannot merge previous GCDA file: corrupt arc tag (0x00000000)
分析:/Users/appfactory/Desktop/WORK/App/trunk/ObjectiveC.gcda:无法合并以前的 GCDA 文件:弧标记损坏 (0x00000000)
It seemed like an Xcode 7 issue that was not fixed in the current Xcode 7.1 beta 2.
这似乎是 Xcode 7 的问题,但在当前的 Xcode 7.1 beta 2 中并未修复。
The problem is caused by failing to merge the existing .gcda coverage files with the current results.
该问题是由于未能将现有 .gcda 覆盖文件与当前结果合并所致。
What I tried:
我试过的:
- Remove those .gcda files with RunScript - does not work in my case
- 使用 RunScript 删除那些 .gcda 文件 - 在我的情况下不起作用
echo "Delete .gcda files" echo "${OBJECT_FILE_DIR_normal}/${CURRENT_ARCH}"
Attention: the ObjectiveC.gcda file may be at a different location!
echo "删除 .gcda 文件" echo "${OBJECT_FILE_DIR_normal}/${CURRENT_ARCH}"
注意:ObjectiveC.gcda 文件可能位于不同的位置!
Set the following build settings to YES - also not helping
Enable Code Coverage Support to YES
Generate Legacy Test Coverage Files to YES
Instrument Program Flow to YES
The solution in my case:
将以下构建设置设置为 YES - 也无济于事
启用代码覆盖支持为 YES
将遗留测试覆盖文件生成为 YES
仪器程序流程为 YES
在我的情况下的解决方案:
Set the following build settings for the main target
为主要目标设置以下构建设置
Enable Code Coverage Support to YES
Generate Legacy Test Coverage Files to YES
Instrument Program Flow to NO
启用代码覆盖支持为 YES
将遗留测试覆盖文件生成为 YES
仪器程序流程到 NO
Set the following build settings for the test target (and any other targets)
为测试目标(和任何其他目标)设置以下构建设置
Enable Code Coverage Support to NO
Generate Legacy Test Coverage Files to NO
Instrument Program Flow to NO
启用代码覆盖支持为 NO
将遗留测试覆盖文件生成为 NO
仪器程序流程到 NO
Hope it helps!
希望能帮助到你!
回答by jmenezes
To resolve the issue of getting "cannot merge previous GCDA file: corrupt arc tag" messages in console, avoid generating ObjectiveC.gcda file, by making “Enable Modules (C and Objective-C)" setting to "NO", in the target settings.
要解决在控制台中获取“无法合并以前的 GCDA 文件:损坏的弧标记”消息的问题,通过将目标中的“启用模块(C 和 Objective-C)”设置为“否”来避免生成 ObjectiveC.gcda 文件设置。