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-DebugSchemeencoding 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.
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,