Code Coverage Converter from Xcode 11 to SonarQube
Since we use a different approach this script/repo is deprecated and will no longer be maintained. I will outline our new approach here since it is probably useful to other people as well.
Instead of using SonarQube's generic code coverage format, we use the llvm-cov
format which is directly supported. No conversion needed!
<derived_data>/Build/ProfileData/*/*.profdata
xcrun llvm-profdata merge <paths to profdata> -output <merged_profdata_file>
<derived_data>/Build/Products/Debug-iphonesimulator/
*.app
binary (includes statically-linked frameworks)xcrun --run llvm-cov show <binary_path> --instr-profile <merged_profdata_file> >> <output_file>
sonar-scanner
sonar.cfamily.llvm-cov.reportPath
(for Obj-C code coverage)sonar.swift.coverage.reportPaths
(for Swift code coverage)cococo is a command line tool to convert Xcode 11's code coverage data to SonarQube's generic code coverage format. It is written in Swift and makes use of multiple threads to speed up the computation.
USAGE: cococo <xcresult> [-e <excluded-file-extension1> ...]
OPTIONS:
--excluded, -e Multiple file extensions which are excluded from processing
--help Display available options
Run the tool for a given xcresult
archive, exclude .h
and .m
files from processing and save the result to sonarqube-generic-coverage.xml
.
cococo myproject.xcresult --excluded .h .m > sonarqube-generic-coverage.xml
The Xcode 11's xcresult
archive can be found in the derived data folder:
DerivedData/YourProject/Logs/Test/*.xcresult
You can download the latest release from here.