We are running an Azure DevOps YAML pipeline to gather code coverage on an iOS swift project. The SonarQubeAnalyze task consistently fails with the error
The only way to get an accurate analysis of C/C++/Objective-C files
is by using the SonarSourcebuild-wrapper and setting the property
"sonar.cfamily.build-wrapper-output" or by using Clang Compilation Database
and setting the property "sonar.cfamily.compile-commands". None of these two
options were specified.
Our configuration is
macOS 14.7.2 Azure hosted agent
Xcode 15.4
SonarQube Server: Server version: 9.9.6.92038
SonarQubePrepare@7 task
SonarQubeAnalyze@7 task
Xcode@5task
We have followed this document Coverage & Test Data Generate Reports for Swift
We have tried using the SonarQube generic coverage format xccov-to-sonarqube-generic.sh
and also xcpretty to generate a compilation database file compile_commands.json
Both methods fail the same way.
The buildwrapper method only works on macOS before version 13 and macOS 13.7.2 is the lowest available on Azure hosted agents.
Attaching the files
compile_commands.json
sonarqube-generic-coverage.xml had to upload with txt extension
The analysis is failing because it detects C / C++ or Objective-C code that it is unable to analyze.
You say you’re trying to analyze a Swift project, but you’ve provided a compile_commands.json file. Can you clarify the languages in your project that you want to analyze versus the full list of languages in your project?
To easily exclude CFamily languages, you can add the following properties to your analysis parameters:
I will run as you suggest. Do these three properties go under extraProperties in the SonarQubePrepare task?
I will run the scripts/xccov-to-sonarqube-generic.sh to generate the sonarqube-generic-coverage.xml file and reference that file in the sonar.coverageReportPaths property
Now that it is running leads me to ask a second question.
In the project there are three different Test schemes.
How do we use the output from three different runs of the xcode task?
Is there a way to combine the three files into one for the analysis?