Dozens of “profiling:invalid arc tag” when running code coverage in Xcode 5

后端 未结 7 2213
隐瞒了意图╮
隐瞒了意图╮ 2020-12-13 05:54

When running my Test target with code coverage enabled in Xcode 5, I get dozens of the following message in the build output:

profiling:invalid arc tag (0x..         


        
相关标签:
7条回答
  • 2020-12-13 06:26

    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:

    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

    0 讨论(0)
  • 2020-12-13 06:27

    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.

    0 讨论(0)
  • 2020-12-13 06:28

    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:

    find . -name "*.gcda" -print0 | xargs -0 rm
    
    0 讨论(0)
  • 2020-12-13 06:28

    You might want to clear out all derived data folders. Especially if you upgrade Xcode or use more than one Xcode versions.

    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.

    find /Library/Developer/XcodeServer -name DerivedData -print0 | xargs -0 rm -rf
    
    0 讨论(0)
  • 2020-12-13 06:38

    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)

    It seemed like an Xcode 7 issue that was not fixed in the current Xcode 7.1 beta 2.

    The problem is caused by failing to merge the existing .gcda coverage files with the current results.

    What I tried:

    1. Remove those .gcda files with RunScript - does not work in my case

    echo "Delete .gcda files" echo "${OBJECT_FILE_DIR_normal}/${CURRENT_ARCH}"

    Attention: the ObjectiveC.gcda file may be at a different location!

    1. 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

    2. The solution in my case:

    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

    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

    Hope it helps!

    0 讨论(0)
  • 2020-12-13 06:42

    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.

    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.

    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.

    0 讨论(0)
提交回复
热议问题