Although codecov-bash could use *.profdata to build a txt report. It fails because it expects *.xctests file to be available in the same directory as *.profdata; this is the case when using Xcode but not when using swift tests - in the latter *.xctests files are in the directory one level above.
codecov-bash could be modified to find the proper input files when using SPM and generate the txt coverage file as usual. Although, it's a redundant operation since the code coverage file has already been exported in JSON; it would make more sense then to just allow codecov-bash to find and parse this file directly.
swift package generate-xcodeproj
is deprecated and will soon be removed.This means that the preferred way to generate code coverage for projects that only supports Swift SPM going forward, will be to use:
The above command generates a
codecov
directory with a*.profdata
file and aJSON
with the code coverage information in the following format https://github.com/llvm/llvm-project/blob/main/llvm/tools/llvm-cov/CoverageExporterJson.cpp.Although
codecov-bash
could use*.profdata
to build atxt
report. It fails because it expects*.xctests
file to be available in the same directory as*.profdata
; this is the case when usingXcode
but not when usingswift tests
- in the latter*.xctests
files are in the directory one level above.codecov-bash
could be modified to find the proper input files when usingSPM
and generate thetxt
coverage file as usual. Although, it's a redundant operation since the code coverage file has already been exported inJSON
; it would make more sense then to just allowcodecov-bash
to find and parse this file directly.