[iOS] Build-wrapper-dump.json file is always empty and Sonar-scanner fails execution

I’m trying to run a scan on my iOS application and upload the scan reports to SonarQube 7.9.2(build 30863).

Sonar Version on local machine

sonar-scanner --version
INFO: Scanner configuration file: /usr/local/Cellar/sonar-scanner/4.2.0.1873/libexec/conf/sonar-scanner.properties
INFO: SonarQube Scanner 4.2.0.1873
INFO: Java 9.0.4 Oracle Corporation (64-bit)
INFO: Mac OS X 10.14.6 x86_64

I’ve downloaded the latest version of Sonar Build-wrapper as mentioned in the document here

With latest build-wrapper, I executed the following commands on Terminal,

build-wrapper-macosx-x86 --out-dir buildOutput xcodebuild -workspace MyApp.xcworkspace -scheme MyApp-DebugScheme -sdk iphonesimulator -configuration Debug -destination ‘platform=iOS Simulator,name=iPhone 11,OS=13.3’ -enableCodeCoverage YES -derivedDataPath DerivedData clean build test

and it resulted in

***** BUILD SUCCEEDED *****

followed by,

***** TEST SUCCEEDED *****

and I’m able to see the Coverage.profdata in DerivedData folder too.

Executed the XC-RUN command to convert Coverage.profddata to txt,

xcrun llvm-cov show -instr-profile=/DerivedData/Build/ProfileData/93661855-37BD-4A15-BABB-D3DB18A1F88F/Coverage.profdata DerivedData/Build/Products/Debug-iphonesimulator/MyApp.app/MyApp > DerivedData/coverage.txt

Coverage file shows the coverage report correctly.

Now, when I execute the sonar-scanner to run the scan and upload to SonarQube, it throws following error,

ERROR: INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 46.336s
INFO: Final Memory: 48M/161M
INFO: ------------------------------------------------------------------------
ERROR: Error during SonarQube Scanner execution
java.lang.IllegalStateException: The “build-wrapper-dump.json” file was found empty. Please make sure that:

  • you are using the latest version of the build-wrapper and the SonarCFamily analyzer
  • your compiler is supported
  • you are wrapping your build correctly
  • you are wrapping a full/clean build
  • if you are building your project inside a Docker container, build-wrapper is wrapping the build process inside the container and not wrapping the external Docker process
    at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:348)
    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.execute(ModuleSensorsExecutor.java:62)
    at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
    at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:400)
    at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:395)
    at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:358)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
    at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:141)
    at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:136)
    at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:122)
    at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:73)
    at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:67)
    at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:564)
    at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
    at com.sun.proxy.$Proxy0.execute(Unknown Source)
    at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
    at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
    at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
    at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
    at org.sonarsource.scanner.cli.Main.main(Main.java:61)
    ERROR:

Following is the sonar properties file (some values are masked for security reasons)

#Login and Hostname
sonar.hostURL=http://xxxx.xxx
sonar.login=xxxxxxxxxxxxxxx

#must be unique in a given SonarQube instance
sonar.projectKey=com.myiosapp

#this is the name displayed in the SonarQube UI
sonar.projectName=My_iOS_App
sonar.projectVersion=1.0

#Path is relative to the sonar-project.properties file. Replace "" by “/” on Windows.
#Since SonarQube 4.2, this property is optional if sonar.modules is set.
#If not set, SonarQube starts looking for source code from the directory containing
#the sonar-project.properties file.
sonar.sources=.

#Xcode project configuration
sonar.objectivec.workspace=MyApp.xcworkspace
sonar.objectivec.projects=MyApp.xcodeproj
sonar.objectivec.appScheme=MyApp-DebugScheme

encoding of the source code. Default is default system encoding
sonar.sourceEncoding=UTF-8

#Paths to exclude from coverage report (tests, 3rd party libraries etc.)// I have hybrid code of Obj-C and Swift, so excluded bridging header
sonar.exclusions=**/MyApp-Bridging-Header.h

#Code coverage report path
sonar.cfamily.llvm-cov.reportPath=DerivedData/coverage.txt

#Sonar Build wrapper override flag
#sonar.cfamily.build-wrapper-output.bypass=true //Commented
sonar.cfamily.build-wrapper-output= DerivedData

I’ve already reviewed the following reference topics on Sonar Community, but nothing seems to help.

ERROR: Error during SonarQube Scanner execution java.lang.IllegalStateException: The “build-wrapper-dump.json” file was found empty

Build wrapper dump json file is found empty

Build wrapper file found but 0 files were analyzed

Any help is very much appreciated.
Thank you,

Hi @mbhadrecha,

we are not supporting the community plugin related to these properties, please do not mix things.

Do you actually have Objective-C files in your project or just Swift files?

I have both Obj-c and Swift files. And I’m using bridging-header for same. Thank you

Hi @mbhadrecha,

could you please make sure you used only SonarSource official plugins and cleanup your configuration file?

Do you mean, remove these properties from Sonar.properties file?

@mpaladin Commented the Xcode project configurations in sonar.properties file, yet same results.

Hi @mbhadrecha,

do you have any *.m file in your project?

yes, there are .h, .m files

Hi @mbhadrecha,

could you please share the content of the build-wrapper output directory?

Two files in build-wrapper directory, following are the contents of them.

build-wrapper.log

Tue Apr 07 15:48:59 2020: build-wrapper, version 3.11 (macosx-x86)

Tue Apr 07 15:48:59 2020: System name: Darwin Nodename: PUNmbhadrechaSAHTD6.local Release: 18.7.0 Version: Darwin Kernel Version 18.7.0: Thu Jan 23 06:52:12 PST 2020; root:xnu-4903.278.25~1/RELEASE_X86_64 Machine: x86_64

Tue Apr 07 15:48:59 2020: socket path: /tmp/build-wrapper-socket.T1lMVb

Tue Apr 07 15:48:59 2020: dynamic library found: /MyApp/sonarBuildWrapper/libinterceptor.dylib

Tue Apr 07 15:48:59 2020: command executed as: <.build-wrapper-macosx-x86>

Tue Apr 07 15:48:59 2020: command line received: <xcodebuild -workspace MyApp.xcworkspace -scheme MyApp-DebugScheme -sdk iphonesimulator -configuration Debug -destination platform=iOS Simulator,name=iPhone 11,OS=13.3 -enableCodeCoverage YES -derivedDataPath DerivedData clean test>

Tue Apr 07 15:48:59 2020: env 0: <TERM_PROGRAM=Apple_Terminal>

Tue Apr 07 15:48:59 2020: env 1: <TERM=xterm-256color>

Tue Apr 07 15:48:59 2020: env 2: <SHELL=/bin/bash>

Tue Apr 07 15:48:59 2020: env 3: <TMPDIR=/var/folders/fq/55f2yv892g34n85rtrnkxmwm0000gn/T/>

Tue Apr 07 15:48:59 2020: env 4: <Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.XmCAfWe1wV/Render>

Tue Apr 07 15:48:59 2020: env 5: <TERM_PROGRAM_VERSION=421.2>

Tue Apr 07 15:48:59 2020: env 6: <TERM_SESSION_ID=834BB50F-4FAC-4D53-A119-AC5220A549B5>

Tue Apr 07 15:48:59 2020: env 7: <LC_ALL=en_US.UTF-8>

Tue Apr 07 15:48:59 2020: env 8: <USER=miteshbhadrecha>

Tue Apr 07 15:48:59 2020: env 9: <SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.2dbS5yLdq7/Listeners>

Tue Apr 07 15:48:59 2020: env 10: <PATH=/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:~/.dotnet/tools:/Library/Frameworks/Mono.framework/Versions/Current/Commands>

Tue Apr 07 15:48:59 2020: env 11: <PWD=/Users/mbhadrecha/Documents/GitRepo/MyApp_iOS>

Tue Apr 07 15:48:59 2020: env 12: <LANG=en_US.UTF-8>

Tue Apr 07 15:48:59 2020: env 13: <XPC_FLAGS=0x0>

Tue Apr 07 15:48:59 2020: env 14: <XPC_SERVICE_NAME=0>

Tue Apr 07 15:48:59 2020: env 15: <HOME=/Users/miteshbhadrecha>

Tue Apr 07 15:48:59 2020: env 16: <SHLVL=1>

Tue Apr 07 15:48:59 2020: env 17: <LOGNAME=miteshbhadrecha>

Tue Apr 07 15:48:59 2020: env 18: <LC_CTYPE=UTF-8>

Tue Apr 07 15:48:59 2020: env 19: <_=.build-wrapper-macosx-x86>

Tue Apr 07 15:48:59 2020: executing: <xcodebuild -workspace MyApp.xcworkspace -scheme MyApp-DebugScheme -sdk iphonesimulator -configuration Debug -destination platform=iOS Simulator,name=iPhone 11,OS=13.3 -enableCodeCoverage YES -derivedDataPath DerivedData clean test>

Tue Apr 07 15:48:59 2020: initializing json file

Tue Apr 07 15:54:51 2020: finalizing json file

Tue Apr 07 15:54:51 2020: returned with code: 65

build-wrapper-dump.json

© SonarSource SA, 2014-2016, contact@sonarsource.com

All SONARSOURCE programs and content are copyright protected.

SONARSOURCE and SONARQUBE are trademarks of SonarSource SA. All rights are expressly reserved.

Hi @mbhadrecha,

you are using a 4 years old version of build wrapper. Please use the latest version 6.8, you should download the build-wrapper from your server as described in the documentation page: https://docs.sonarqube.org/latest/analysis/languages/cfamily/.

Hello Massimo,

What’s the SonarQube URL in

Download Build Wrapper for macOS from {SonarQube URL}/static/cpp/build-wrapper-macosx-x86.zip

Appreciate your help.
Thank you.

Hi @mbhadrecha,

it’s the URL to your SonarQube instance, as easy as it is written.