I have been trying this for a couple of days to get the code coverage on the sonar cloud, but the sonar cloud is not able to detect the test cases and shows 0% code coverage.
Specification: Xcode version: 13.2.1, Mac OS X 12.2.1
It looks like the error you’re receiving doesn’t have anything to do with code coverage – but that your scan is running without being pointed to -Dsonar.host.url=https://sonarcloud.io and probably without the required sonar.organization and sonar.projectKey configuration.
Presumably, you have an analysis somewhere that is already successfully analyzing (and where 0% code coverage is being reported). When you’re running your regular project (not the example), where are you running it? In a particular CI (GitHub actions, Bitbucket Pipelines, etc.)
Please do not bump threads – and certainly not when your last update was mid-day on a Friday. While we are happy to provide free support to our users, please be respectful.
The bitbucket-pipelines.yml file doesn’t actually show how you produce the code coverage report (which to be clear should be generated each time, and not stored in your repository).
The code coverage should also be produced on the same machine where analysis takes place (so running analysis on a linux gcc container when coverage was produced on a macOS machine won’t work).
I am building my code on my local device(MacBook).
After successfully testing my code on Xcode the process we are following is as follows:
I am building the project on my local machine with xcodebuild -project swift-coverage-example.xcodeproj/ -scheme swift-coverage-example -derivedDataPath Build/ -enableCodeCoverage YES clean build test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO
and the script I am using xccov-to-sonarqube-generic.sh you can find here https://github.com/SonarSource/sonar-scanning-examples/blob/master/swift-coverage/swift-coverage-example/xccov-to-sonarqube-generic.sh
** This command will generate a generic code coverage report.
Then committing the changes to BitBucket.
PFA bitbucket-pipeline.yml file and generic code coverage file,