diff --git a/swift-coverage/README.md b/swift-coverage/README.md index 06de8682..2cc04a0a 100644 --- a/swift-coverage/README.md +++ b/swift-coverage/README.md @@ -23,7 +23,8 @@ XCode version | Command --- | --- XCode 8+ - 9.2 | `xcrun llvm-cov show -instr-profile=Build/ProfileData//Coverage.profdata Build/Products/Debug/swift-coverage-example.app/Contents/MacOS/swift-coverage-example > Coverage.report` XCode 9.3 - 9.4.1 | `bash xccov-to-sonarqube-generic.sh Build/Logs/Test/*.xccovarchive/ > sonarqube-generic-coverage.xml` -XCode 10+ | `bash xccov-to-sonarqube-generic.sh Build/Logs/Test/*.xcresult/*_Test/*.xccovarchive/ > sonarqube-generic-coverage.xml` +XCode 10 | `bash xccov-to-sonarqube-generic.sh Build/Logs/Test/*.xcresult/*_Test/*.xccovarchive/ > sonarqube-generic-coverage.xml` +XCode 11 | `bash xccov-to-sonarqube-generic.sh Build/Logs/Test/*.xcresult/ > sonarqube-generic-coverage.xml` 1.c Import code coverage report diff --git a/swift-coverage/swift-coverage-example/xccov-to-sonarqube-generic.sh b/swift-coverage/swift-coverage-example/xccov-to-sonarqube-generic.sh index 7b4f258a..bb2edbc6 100644 --- a/swift-coverage/swift-coverage-example/xccov-to-sonarqube-generic.sh +++ b/swift-coverage/swift-coverage-example/xccov-to-sonarqube-generic.sh @@ -4,8 +4,9 @@ set -euo pipefail function convert_file { local xccovarchive_file="$1" local file_name="$2" + local xccov_options="$3" echo " " - xcrun xccov view --file "$file_name" "$xccovarchive_file" | \ + xcrun xccov view $xccov_options --file "$file_name" "$xccovarchive_file" | \ sed -n ' s/^ *\([0-9][0-9]*\): 0.*$/ /p; s/^ *\([0-9][0-9]*\): [1-9].*$/ /p @@ -16,8 +17,12 @@ function convert_file { function xccov_to_generic { echo '' for xccovarchive_file in "$@"; do - xcrun xccov view --file-list "$xccovarchive_file" | while read -r file_name; do - convert_file "$xccovarchive_file" "$file_name" + local xccov_options="" + if [[ $xccovarchive_file == *".xcresult"* ]]; then + xccov_options="--archive" + fi + xcrun xccov view $xccov_options --file-list "$xccovarchive_file" | while read -r file_name; do + convert_file "$xccovarchive_file" "$file_name" "$xccov_options" done done echo ''