Help on getting xcode coverage data imported into sonarcloud


I’m trying to get code coverage data imported into sonarcloud.
The project I’m testing, is an iOS app, with a mix of objective-c, swift and c++.

I tried following the guide swift guide:

Which does leave me with a xml file I can upload, but I don’t get any coverage data on sonarcloud after I do.

I also tried following:

Where I wrap my xcode clean test command with your buildwrapper.
However I get an error:
The “build-wrapper-dump.json” file was found empty.

At this point, I’m unsure how to proceed.

I have a working xcode build command, which outputs coverage data into a xcresult file, which I can open and verify in xcode.

I’m able to convert that xcresult file into xml using your script, however this step is really painfully slow on my mac m1 air.

Any help on steps to try is appreciated.

The goal is ending up with coverage data in sonarcloud for swift and objective-c and c++ files.

I’m able to upload results to sonarcloud by adding


to my config file.

However I then get:

INFO: Coverage data ignored for 6415 unknown files, including:

in my output when running sonar-scanner, those 6000 ish files, is the ones I’m really interested in.

I got coverage data to show up. I had path-names wrong between the coverage report I ran on, and the sources I supplied sonar-scanner.

My issue is still, I have coverage data for objc files, but I can’t get the buildwrapper to work. So I have to put


in my config to get results uploaded.

Is there a easy way to include coverage data for objc files, without running the static analysis?

Hey there.

It’s not possible to add coverage to files that aren’t analyzed by the scanner.

What issues are you facing using the build wrapper? There’s a lot of value in the analysis, and rather than focusing just on coverage data it would be great to have it all working end-to-end for you :slight_smile:

Hello @dj-foreflight,

You are using apple m1. build-wrapper still doesn’t support it. Ticket.

We support a compilation database(which can be generated by many tools) as an alternative to build-wrapper to unblock such cases.
Have a look at this blog post and the documentation:


Thanks for the hint.

I tried getting up and running with a compilation database using the following commands:

xcodebuild clean test | tee xcodebuild.log | xcpretty --report json-compilation-database

I remember to set


when running sonar-scanner after I eventually get:

java.lang.IllegalArgumentException: Start pointer [line=1545, lineOffset=4] should be before end pointer [line=1545, lineOffset=4]
ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: java.lang.IllegalArgumentException: Start pointer [line=1545, lineOffset=4] should be before end pointer [line=1545, lineOffset=4]
	at com.sonar.cpp.analyzer.AnalysisExecutor.submit(
	at com.sonar.cpp.plugin.CFamilySensor.process(
	at com.sonar.cpp.plugin.CFamilySensor.lambda$process$12(
	at com.sonar.cpp.plugin.CompileCommandsReader.readCaptures(
	at com.sonar.cpp.plugin.CFamilySensor.process(
	at com.sonar.cpp.plugin.CFamilySensor.process(
	at com.sonar.cpp.plugin.CFamilySensor.execute(
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(
	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(
	at org.sonar.core.platform.ComponentContainer.startComponents(
	at org.sonar.core.platform.ComponentContainer.execute(
	at org.sonar.scanner.scan.ProjectScanContainer.scan(
	at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(
	at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(
	at org.sonar.core.platform.ComponentContainer.startComponents(
	at org.sonar.core.platform.ComponentContainer.execute(
	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(
	at org.sonar.core.platform.ComponentContainer.startComponents(
	at org.sonar.core.platform.ComponentContainer.execute(
	at org.sonar.batch.bootstrapper.Batch.doExecute(
	at org.sonar.batch.bootstrapper.Batch.execute(
	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
	at java.base/java.lang.reflect.Method.invoke(Unknown Source)
	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(
	at com.sun.proxy.$Proxy0.execute(Unknown Source)
	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(
	at org.sonarsource.scanner.api.EmbeddedScanner.execute(
	at org.sonarsource.scanner.cli.Main.execute(
	at org.sonarsource.scanner.cli.Main.execute(
	at org.sonarsource.scanner.cli.Main.main(
Caused by: java.lang.IllegalArgumentException: Start pointer [line=1545, lineOffset=4] should be before end pointer [line=1545, lineOffset=4]
	at org.sonar.api.utils.Preconditions.checkArgument(
	at org.sonar.api.batch.fs.internal.DefaultInputFile.newRangeValidPointers(
	at org.sonar.api.batch.fs.internal.DefaultInputFile.newRange(
	at com.sonar.cpp.plugin.CFamilySensor.rangeOrNull(
	at com.sonar.cpp.plugin.CFamilySensor.saveSymbols(
	at com.sonar.cpp.plugin.CFamilySensor.lambda$process$14(
	at com.sonar.cpp.analyzer.AnalysisExecutor.lambda$submit$0(
	at java.base/java.util.concurrent.Executors$ Source)
	at java.base/ Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$ Source)
	at java.base/ Source)

I’m running
INFO: SonarScanner

Hello @dj-foreflight,

Can you upload the full log of the scanner in verbose mode?
Let me know if you prefer to share them privately.


I prefer to share privately.

Can you pm me?