Hi, I have added xccov-to-sonarqube-generic.sh and sonar-project.properties in my project folder. Script is as follows:
#!/usr/bin/env bash
set -euo pipefail
function convert_file {
local xccovarchive_file="$1"
local file_name="$2"
local xccov_options="$3"
echo " <file path="$file_name">"
xcrun xccov view $xccov_options --file “$file_name” “$xccovarchive_file” | \
sed -n ’
s/^ ([0-9][0-9]): 0.*$/ <lineToCover lineNumber="\1" covered=“false”/>/p;
s/^ ([0-9][0-9]): [1-9].*$/ <lineToCover lineNumber="\1" covered=“true”/>/p
’
echo ’ ’
}
function xccov_to_generic {
echo ‘’
for xccovarchive_file in “$@”; do
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 ‘’
}
xccov_to_generic “$@”
I am following these 2 steps:
Step 1: xcodebuild -project xxx.xcodeproj/ -scheme xxx -derivedDataPath Build/ -enableCodeCoverage YES clean build test CODE_SIGNING_ALLOWED=NO CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -destination 'platform=iOS Simulator,name=iPhone 12 Pro Max,OS=14.3
Step 2: bash xccov-to-sonarqube-generic.sh Build/Logs/Test/*.xcresult/ > sonarqube-generic-coverage.xml
Step 2 is giving me this error:
Requested but did not find extension point with identifier Xcode.IDEFoundation.IDEResultKitSerializationConverter
Error: Error Domain=XCCovErrorDomain Code=0 “Failed to load coverage report for scheme action ‘Testing project xxx with scheme xxx’ in result bundle” UserInfo={NSLocalizedDescription=Failed to load coverage report for scheme action ‘Testing project xxx with scheme xxx’ in result bundle, NSUnderlyingError=0x7faf54ff4290 {Error Domain=NSCocoaErrorDomain Code=260 “The file “action.xccovreport” couldn’t be opened because there is no such file.” UserInfo={NSFilePath=/tmp/action.xccovreport, NSUnderlyingError=0x7faf54ff50d0 {Error Domain=NSPOSIXErrorDomain Code=2 “No such file or directory”}}}}
Can anyone help me with this? I am using Xcode 12.3 and following exact steps mentioned in sonar-scanning-examples/swift-coverage at master · SonarSource/sonar-scanning-examples · GitHub.