Code coverage for swift Xcode 11

Hi, all!

I’m curious to know the reason SonarQube documentation states to use the script to convert coverage data to sonar generic type for swift project on Xcode 11. I just tried to submit .llcov report and it seems to work just fine. The reason I’m asking is that I have Objective-C file in the project as well and sonar-scanner was quite unhappy with that with the following line: Caused by: Line 32930 of report refers to a file with an unknown language:. Is there a way to fix it? Not being sure what it could be connected with leaves me with no other options rather than looking for a way to expclude .m files, but I could not find such an option.

As I said earlier, also curios, if I can continue to use llcov report, which seems to work just fine (am I missing something? Would some functionality not work because of that?).

I am using:

  • SonarQube Scanner 4.2.0.1873
  • Xcode 11.3.1

I was able to fix it by adding .m to exclusions list, but surprisingly (or not surprisingly) got same results using two different reports: generated by slather (llvcov) and generated by script provided by Sonar using command in the example.

A post was split to a new topic: Swift Coverage report generation fails

Hi @wise_Kaa

Thank you for your message, but it’s not clear to me what’s exactly your question or problem (there are too many in your initial message). Next time please spend some time clarifying that for yourself so that others could help you.

As far as I understood you have a project with both Swift and Obj-C code.

Could you share full logs and describe which analysis properties you use to import coverage?

Hi @Lena
Its showing EXECUTION SUCCESS but code coverage and issues not updating on Sonarqube localhost server http://localhost:9000/projects
and also showing The main branch has no lines of code.

Please check my logs

 0:54:57.062 DEBUG: Sensors : SonarCSS Rules -> JaCoCo XML Report Importer -> JavaXmlSensor -> HTML
20:54:57.063 INFO: Sensor SonarCSS Rules [cssfamily]
20:54:57.064 INFO: No CSS, PHP, HTML or VueJS files are found in the project. CSS analysis is skipped.
20:54:57.064 INFO: Sensor SonarCSS Rules [cssfamily] (done) | time=1ms
20:54:57.064 INFO: Sensor JaCoCo XML Report Importer [jacoco]
20:54:57.066 INFO: Importing 1 report(s). Turn your logs in debug mode in order to see the exhaustive list.
20:54:57.066 DEBUG: Reading report '/Users/kishore.kumar/Downloads/sonar-scanning-examples-master/swift-coverage/swift-coverage-example/sonarqube-generic-coverage.xml'
20:54:57.072 INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=8ms
20:54:57.072 INFO: Sensor JavaXmlSensor [java]
20:54:57.073 INFO: Sensor JavaXmlSensor [java] (done) | time=1ms
20:54:57.073 INFO: Sensor HTML [web]
20:54:57.075 INFO: Sensor HTML [web] (done) | time=2ms
20:54:57.078 INFO: ------------- Run sensors on project
20:54:57.080 DEBUG: 'Generic Coverage Report' skipped because one of the required properties is missing
20:54:57.080 DEBUG: 'Java CPD Block Indexer' skipped because there is no related file in current project
20:54:57.081 DEBUG: Sensors : Zero Coverage Sensor
20:54:57.081 INFO: Sensor Zero Coverage Sensor
20:54:57.082 INFO: Sensor Zero Coverage Sensor (done) | time=1ms

20:54:57.104 DEBUG: SCM revision ID '0765cbdf24f2d2df55702a44ab6668cb6a3e8b32'
20:54:57.159 INFO: Analysis report generated in 71ms, dir size=79 KB
20:54:57.182 INFO: Analysis report compressed in 22ms, zip size=10 KB
20:54:57.182 INFO: Analysis report generated in /Users/kishore.kumar/Downloads/sonar-scanning-examples-master/swift-coverage/swift-coverage-example/.scannerwork/scanner-report
20:54:57.182 DEBUG: Upload report
20:54:57.466 DEBUG: POST 200 http://localhost:9000/api/ce/submit?projectKey=swift-coverage-example&projectName=swift-coverage-example | time=283ms
20:54:57.470 INFO: Analysis report uploaded in 288ms
20:54:57.471 DEBUG: Report metadata written to /Users/kishore.kumar/Downloads/sonar-scanning-examples-master/swift-coverage/swift-coverage-example/.scannerwork/report-task.txt
20:54:57.471 INFO: ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard?id=swift-coverage-example
20:54:57.471 INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report
20:54:57.471 INFO: More about the report processing at http://localhost:9000/api/ce/task?id=AXPjRjrusZcFenhLnq2u
20:54:57.473 DEBUG: Post-jobs : 
20:54:57.476 INFO: Analysis total time: 44.154 s
20:54:57.478 INFO: ------------------------------------------------------------------------
20:54:57.478 INFO: EXECUTION SUCCESS
20:54:57.478 INFO: ------------------------------------------------------------------------
20:54:57.478 INFO: Total time: 45.717s
20:54:57.498 INFO: Final Memory: 13M/50M
20:54:57.499 INFO: ------------------------------------------------------------------------