Converting the coverage report to xml format to be read by sonarqube for ios application

we are using sonarqube * Developer Edition Version 8.9.7 (build 52159). We have an IOS application which was developed using swift language. our requirement is to generate a code coverage report and convert it into a format readable by sonarqube so the code coverage percent will be displayed on the project dashboard.
We have generated a coverage report using multiple ways like slather and also using the command
xcodebuild -project project.xcodeproj -scheme SCHEME-destination ‘platform=iOS Simulator,name=iPhone xxxxxx’ -configuration Debug ENABLE_CODE_COVERAGE=YES clean build test. the report is being generated in .xcreport format and i have tried converting it into xml format by following this sonar-scanning-examples/swift-coverage/swift-coverage-example/xccov-to-sonarqube-generic.sh at master · SonarSource/sonar-scanning-examples · GitHub. so i have created a .sh file and copied the contents of the file and used the below command

bash xccov-to-sonarqube-generic.sh Build/Logs/Test/Run-swift-coverage-example-2023.01.27_16-07-44-+0100.xcresult/ >Coverage.xml

this is converting the file to Coverage.xml format but the thing is when executing the sonar-scan command we see the following error

INFO: ------------- Run sensors on project
INFO: Sensor Generic Coverage Report
INFO: Parsing /Users/xxxx/Library/Developer/Xcode/DerivedData/Project-fffqrfnevokmtpeqhsuprnfzjfkl/Logs/Test/coverage.xml
INFO: Imported coverage data for 0 files
INFO: Coverage data ignored for 492 unknown files, including:
/Users/xxxx/Library/Developer/Xcode/DerivedData/Project-fffqrfnevokmtpeqhsuprnfzjfkl/SourcePackages/checkouts/KeychainAccess/Lib/KeychainAccess/Keychain.swift
/Users/xxxx/Library/Developer/Xcode/DerivedData/Project-fffqrfnevokmtpeqhsuprnfzjfkl/SourcePackages/checkouts/pexip-swift-sdk/Sources/PexipCore/DataChannel.swift
/Users/xxxx/Library/Developer/Xcode/DerivedData/Project-fffqrfnevokmtpeqhsuprnfzjfkl/SourcePackages/checkouts/pexip-swift-sdk/Sources/PexipCore/DTMFSignals.swift
/Users/xxxx/Library/Developer/Xcode/DerivedData/Project-fffqrfnevokmtpeqhsuprnfzjfkl/SourcePackages/checkouts/pexip-swift-sdk/Sources/PexipCore/IceServer.swift
/Users/xxxx/Library/Developer/Xcode/DerivedData/Project-fffqrfnevokmtpeqhsuprnfzjfkl/SourcePackages/checkouts/pexip-swift-sdk/Sources/PexipCore/Isolated.swift
INFO: Sensor Generic Coverage Report (done) | time=97ms
INFO: Sensor Zero Coverage Sensor

Is anyone facing the same issue?Can someone please help me on this?

Thankyou in advance

Hi,

Welcome to the community!

Your version is past EOL. You should upgrade to either the latest version or the current LTS at your earliest convenience. Your upgrade path is:

8.9.7 → 9.9.3 → 10.3 (last step optional)

You may find these resources helpful:

If you have questions about upgrading, feel free to open a new thread for that here.

Regarding your question, the error indicates that the paths in the report don’t match the paths analysis sees. You’ll need to reconcile the pathing in the report.

 
HTH,
Ann

Hi Ann,

Thanks for the response. But the path of the coverage report is being mentioned in the sonar-project.properties file , Can you please suggest me with an example?

Thanks,
Samhitha

xcodebuild test -workspace xxx.xcworkspace -scheme xxx -destination “platform=iOS Simulator,name=iPhone 15 Pro” -derivedDataPath Build/ -enableCodeCoverage YES -resultBundlePath TestResults/TestResults.xcresult
TestResults/TestResults.xcresult is created in the project directory.

find TestResults -name “*.xcresult” -exec bash xccov-to-sonarqube-generic.sh {} >> coverage.xml ;

  • Coverage.xml is generated using xccov-to-sonarqube-generic.sh.

-Pay attention to the parameters when using a sonar scanner. I came across your problem while dealing with the same issue. This way the sonarqube file went smoothly

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.