Coverage of Swift Project is Zero Percentage

Hi, I have swift project and I am running azure pipeline to analyse project. After analysis when I see the reports on SonarCloud for swift project, It shows 0.0% coverage.I have attached the screenshot for reference.
sonar-properties configuration is

sonar.projectName=ProjectName
sonar.projectKey=Key
sonar.organization= org
sonar.projectVersion=1.0

# =====================================================
#   Properties that will be shared amongst all modules
# =====================================================

# SQ standard properties
sonar.sources=Name

# Properties to cover test-cases
sonar.test.inclusions=**/*Test*/**
sonar.test.inclusions=*.swift
sonar.exclusions=**/*.xml,Pods/**/*,Reports/**/*
sonar.tests= NameTests

# Properties remove c,c++, obj-c files path
sonar.c.file.suffixes=-
sonar.cpp.file.suffixes=- 
sonar.objc.file.suffixes=-

# Properties specific to the C and C++ analyzer:
sonar.cfamily.build-wrapper-output=build_wrapper_output_directory```

Screenshot of SonarCloud

Hi,

You don’t appear to be feeding a coverage report into analysis.

 
HTH,
Ann

Hi,
I write command for coverage path, but got this below error.
ERROR: Error during SonarScanner execution ERROR: Error during parsing of the generic coverage report ‘/Users/runner/work/1/s/sonarqube-generic-coverage.xml’. Look at SonarQube documentation to know the expected XML format. ERROR: Caused by: /Users/runner/work/1/s/sonarqube-generic-coverage.xml (No such file or directory) ERROR: ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.

Hi,

Did you provide a file in the correct format?

 
Ann

Hi,
I am bit confused on this. Which file I need to provide and also on which path?

Regards,
Yasir

Hi Yasir,

You determine the path with the value you provide to the analysis parameter.

Your steps:

 
HTH,
Ann

Hi Ann,
I followed the above steps and still getting this below error.

##[error]ERROR: Error during parsing of the generic coverage report ‘/Users/runner/work/1/s/sonarqube-generic-coverage.xml’. Look at SonarQube documentation to know the expected XML format.

Hi,

Have you compared the file you’re passing in to analysis with the expected format?

 
Ann

Hi,
Yes, I compared the file passing for analysis and format also seems correct.

Yasir

Hi Yasir,

Would you care to provide the report and the property you’re using to pass it into analysis?

 
Ann

Hi Ann,
I am using below commands

  1. xcodebuild -project MyProject/ -scheme MyProject -derivedDataPath Build/ -enableCodeCoverage YES clean build test CODE_SIGN_IDENTITY=“” CODE_SIGNING_REQUIRED=NO
  2. bash xccov-to-sonarqube-generic.sh Build/Logs/Test/*.xcresult/ > sonarqube-generic-coverage.xml

Facing this error on above command

xccov-to-sonarqube-generic.sh: line 67: jq: command not found
Error: Error Domain=XCCovErrorDomain Code=0 "Failed to create unarchiver" UserInfo={NSLocalizedDescription=Failed to create unarchiver, NSUnderlyingError=0x600000ab93e0 {Error Domain=NSCocoaErrorDomain Code=260 "The file “Metadata.plist” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/Users/maxhina/Documents/Tapcheck/tmp.xccovarchive/Metadata.plist, NSUnderlyingError=0x600000ab85a0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}}}

  1. sonar.coverageReportPaths=sonarqube-generic-coverage.xml for sonar-properties file

Hi,

The README on that is pretty clear that jq is required:

 
HTH,
Ann

Hi,
Still facing below error on this command using Xcode 13
bash xccov-to-sonarqube-generic.sh Build/Logs/Test/*.xcresult/ > sonarqube-generic-coverage.xml

Error: Error Domain=XCCovErrorDomain Code=0 "Failed to create unarchiver" UserInfo={NSLocalizedDescription=Failed to create unarchiver, NSUnderlyingError=0x600002361110 {Error Domain=NSCocoaErrorDomain Code=260 "The file “Metadata.plist” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/Users/maxhina/Documents/Tapcheck/tmp.xccovarchive/Metadata.plist, NSUnderlyingError=0x600002361050 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}}}