Problems exporting Xcode14 unit test report to Sonar

I have an Xcode Project, using the Swift language, with some Unit tests, that I am trying to export the coverage information to Sonar. I have faced some issues, but first of all…

versions:

  • SonarQube 9.7.1
  • SonarScanner 4.7.0.2747
  • Java 11.0.16.1 Homebrew (64-bit)
  • Mac OS X 12.6 x86_64
  • Xcode 14.0

So far I tried some things:

The problems:

1 - The generated sonarqube-generic-coverage.xml file came with some wrong characters: &. I had to remove this in order to the Sonar scanner works.

2 - After that the Sonar Scanner had been completed, but the coverage information was 0%. Checking the error/warning outputs I could realize that the following message appeared for every class:

DEBUG: Skipping file '<< MY CLASS >>'in the generic coverage report because it doesn’t have a known language.

The project language is swift, and its contemplated in the properties file:

There is no “-Dsonar.objc.file.suffixes=-” in my properties.

I have already tried lots of thins, but I am still not able to see my code coverage in the Sonar.

What should I do? Is there any updated tutorial about using Sonar to see the Swift Xcode project, coverage and etc?

I already appreciate

Hi,

Welcome to the community!

Can you share your analysis log?

The analysis / scanner log is what’s output from the analysis command. Hopefully, the log you provide - redacted as necessary - will include that command as well.

This guide will help you find them.

 
Ann

Hello Ann!

Thanks for the answer!

The Swift Code Quality and Security Sensor is not appearing in the execution logs, neither skipped nor used (we are searching for the output file for the Swift Sensor right?).

It’s not possible to insert the whole execution log here because it crosses the character limit here in the post. :frowning:

I found an analysis.log file in the PROJECT_FOLDER/.scannerwork/scanner-report/analysis.log. Don’t know if it helps

The content is:

Plugins:
Bundled analyzers:
  - Python Code Quality and Security 3.19.0.10254 (python)
  - Go Code Quality and Security 1.11.0.3905 (go)
  - JaCoCo 1.1.1.1157 (jacoco)
  - Kotlin Code Quality and Security 2.10.0.1456 (kotlin)
  - IaC Code Quality and Security 1.9.2.2279 (iac)
  - JavaScript/TypeScript/CSS Code Quality and Security 9.9.0.19492 (javascript)
  - Ruby Code Quality and Security 1.11.0.3905 (ruby)
  - Scala Code Quality and Security 1.11.0.3905 (sonarscala)
  - C# Code Quality and Security 8.46.0.54807 (csharp)
  - Java Code Quality and Security 7.14.0.30229 (java)
  - HTML Code Quality and Security 3.6.0.3106 (web)
  - Flex Code Quality and Security 2.7.0.2865 (flex)
  - XML Code Quality and Security 2.6.1.3686 (xml)
  - PHP Code Quality and Security 3.25.0.9077 (php)
  - Text file Code Quality and Security 1.1.0.282 (text)
  - VB.NET Code Quality and Security 8.46.0.54807 (vbnet)
  - Configuration detection fot Code Quality and Security 1.2.0.267 (config)
Global server settings:
  - sonar.core.id=147B411E-AYSAvlDHcNkRtuup0yuI
  - sonar.core.startTime=2022-12-02T16:29:34-0300
  - sonar.forceAuthentication=true
Project server settings:
Project scanner properties:
  - sonar.coverageReportPaths=sonarqube-generic-coverage.xml
  - sonar.exclusions=**/*.xml,Pods/**/*,Reports/**/*
  - sonar.host.url=http://localhost:9000
  - sonar.language=Swift
  - sonar.login=******
  - sonar.password=******
  - sonar.projectBaseDir=/Users/filiponegrao/projects/mobilidade-app-ios
  - sonar.projectDescription=prjDescription
  - sonar.projectKey=Teste-Renner
  - sonar.projectName=Teste-Renner
  - sonar.scanner.app=ScannerCLI
  - sonar.scanner.appVersion=4.7.0.2747
  - sonar.sourceEncoding=UTF-8
  - sonar.sources=.
  - sonar.swift.appConfiguration=Debug
  - sonar.swift.appScheme=RennerMobile
  - sonar.swift.excludedPathsFromCoverage=.*Tests.*
  - sonar.swift.project=RennerMobile.xcodeproj
  - sonar.swift.simulator=platform=iOS Simulator,name=iPhone SE (2nd generation),OS=15.0
  - sonar.swift.tailor.config=--no-color --max-line-length=100 --max-file-length=500 --max-name-length=40 --max-name-length=40 --min-name-length=4
  - sonar.swift.workspace=RennerMobile.xcworkspace
  - sonar.test.inclusions=*.swift
  - sonar.tests=LojasRennerUnitTests
  - sonar.verbose=true
  - sonar.working.directory=/Users/filiponegrao/projects/mobilidade-app-ios/.scannerwork

Any ideas?

Thanks in advance

Hi,

What edition are you using? You can check in the page footer. I’m guessing you’re on Community Edition, which doesn’t include Swift.

 
Ann

Wow! I am definitely using Community version:

I didn’t know Swift language it was only included on payed versions.

Hi,

Prices for Developer Edition($), which includes Swift, are very reasonable for small instances. :smiley:

 
HTH,
Ann

1 Like

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