Reputation: 229
We are using Xcode 7 and 8 (beta). Apple has deprecated GCOV code coverage in XCode 7 and removed it entirely in XCode 8. Therefore we are trying to move to exporting profdata files.
We need to be able to generate code coverage files (profdata/profraw but not gcno or gcda) while performing manual tasks, and here's what I've tried:
GTM_CONFIGURATION_OTHER_CFLAGS = -fprofile-instr-generate -fcoverage-mapping
As well as
//If enabled, passes flag -fprofile-instr-generate and -fprofile-instr-generate
CLANG_INSTRUMENT_FOR_OPTIMIZATION_PROFILING = YES
I know how to get code coverage running for XCTests, but in this case, I need to also be able to generate it while doing a manual run.
Upvotes: 0
Views: 1705
Reputation: 39
Looks like int __llvm_profile_write_file(void)
works for Obj C projects in pair with CLANG_INSTRUMENT_FOR_OPTIMIZATION_PROFILING
. But as long as you add one swift file in the project swift will complain.. Swift does not support profile guided optimization.
. Are there any workarounds?
Upvotes: 0
Reputation: 26
I believe, but have not tried, that this can be accomplished by calling __llvm_profile_write_file(void) from within your code. You will need to forward declare it, and figure out a way to trigger the call when you need it. Noteworthy is that the resulting file will continue to aggregate coverage from the entire execution, and that you may want to make a copy of the generated file if you want to compare coverage from different stages of execution.
I found some of the details for this here: http://clang.llvm.org/docs/SourceBasedCodeCoverage.html
"Forward-declare int __llvm_profile_write_file(void) and call it to write out a profile. This function returns 0 when it succeeds, and a non-zero value otherwise. Calling this function multiple times appends profile data to an existing on-disk raw profile."
Upvotes: 1