When we run the Azure DevOps iOS pipeline, we encountered an issue with SonarQube. Although the pipeline was completed successfully, it did not display any code coverage on the SonarQube dashboard due to the Swift-plugin.
Error Message -
[Fatal Error] coverage-04.dtd:1:2: The markup declarations contained or pointed to by the document type declaration must be well-formed.
ERROR: Error processing file named sonar-reports/coverage-swift.xml
org.xml.sax.SAXParseException: The markup declarations contained or pointed to by the document type declaration must be well-formed.
This issue is related to the Swift plugin and the coverage.xml file. The community edition does not support Swift, so we installed the Swift plugin with a custom Sonar image. It was working fine until a few days ago, but now it is causing problems.
XCODE version
/Applications/Xcode_15.3.app/Contents/Developer
Xcode 15.3
Build version 15E204a
SonarQube version
- Community Edition
- Version 8.5.1 (build 38104)
Sonarscaner version
INFO: SonarScanner 5.0.1.3006
INFO: Java 17.0.7 Eclipse Adoptium (64-bit)
INFO: Mac OS X 14.4.1 x86_64
error logs
INFO: Sensor Surefire [backelitesonarswiftplugin] (done) | time=110ms
INFO: Sensor Cobertura [backelitesonarswiftplugin]
INFO: Processing Cobertura report sonar-reports/coverage-swift.xml
[Fatal Error] coverage-04.dtd:1:2: The markup declarations contained or pointed to by the document type declaration must be well-formed.
ERROR: Error processing file named sonar-reports/coverage-swift.xml
org.xml.sax.SAXParseException: The markup declarations contained or pointed to by the document type declaration must be well-formed.
at java.xml/com.sun.org.apache.xerces.internal.parsers.DOMParser.parse(Unknown Source)
at java.xml/com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderImpl.parse(Unknown Source)
at java.xml/javax.xml.parsers.DocumentBuilder.parse(Unknown Source)
at com.backelite.sonarqube.swift.coverage.CoberturaReportParser.parseReport(CoberturaReportParser.java:60)
at com.backelite.sonarqube.swift.coverage.CoberturaSensor.execute(CoberturaSensor.java:69)
at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.lambda$execute$1(ModuleSensorsExecutor.java:59)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.withModuleStrategy(ModuleSensorsExecutor.java:77)
at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:59)
at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:393)
at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:389)