The "build-wrapper-dump.json" file was found empty. (Project with mixed ObjC and Swift)

Hello Community!

I’m facing a problem after running sonar-scanner. I’ve searched here topics related to my issue but solutions don’t seem apply to my case.

My problem seems to be the same as this post but I could not get enough information about the solution:

I am new to SonarQube and would like to ask for help from anyone here. :slight_smile:

Btw, initially, it was working fine when scanning only for Swift as I forgot to include to scan Objective C files as well.

Must-share information (formatted with Markdown):

Which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)

  1. SonarQube 9.6.0.59041
  2. SonarScanner 4.7.0.2747
  3. BuildWrapper 6.20.3

What are you trying to achieve
I’m trying to scan my project with mixed objective c and swift languages.

What have you tried so far to achieve this

1.Ran build_wrapper command below:

build-wrapper-macosx-x86 --out-dir bw-output xcodebuild clean
  1. Ran code below:
sonar-scanner

I’ve attached my sonar-project.properties, build-wrapper-dump.json and screen shot of build-wrapper.log

myfiles.zip (1016.0 KB)

P.S. I had to cover some paths and remove project names due to privacy.

Update:
I got The main branch has no lines of code. warning/error after adding the following in my sonar-project.properties:

sonar.verbose=true
sonar.cfamily.threads=5
sonar.cfamily.cache.enabled=true
sonar.cfamily.cache.path=relative_or_absolute_path_to_cache_location

Can anyone help know what I did wrong or what I’m missing?

Hey there.

Before any further troubleshooting, I think it’s important that you address the version of the build wrapper you’re using.

This is the version that came bundled with SonarQube v8.9 LTS, not v9.6 (which should be 6.36).

Can you make sure you’re using the version of the build wrapper offered by your current SonarQube server, and see if the build wrapper output changes?

Hey @Colin

Thanks for your reply!

Sorry, I wrote the wrong version I am using here.

My build wrapper version is 6.36 (macosx-x86)

I am not getting “build-wrapper-dump.json” file was found empty anymore.
However, I have another problem now. My project on SonarQube says my main branch doesn’t have lines of code:

My configs are still the same.

I don’t understand why and what I’m missing.

Do you scanner logs show that files are being indexed (and not somehow excluded)? Are any other branches being analyzed under this project?

@Colin

I don’t think there’s anything being scanned.

This is the screenshot of my sonar-properties (i had to remove names and ids)

Your inclusion is configured to only analyze files in the directory from which the scan is launched. You would need to change it to sonar.inclusions=**/*.swift for example.

@Colin

Thanks! That fix it!

Now I’m getting errors with commands i tried:

  1. build_wrapper_output_directory
    sonar-property
    sonar.cfamily.build-wrapper-output=build_wrapper_output_directory
    Command:
    build-wrapper-macosx-x86 --out-dir build_wrapper_output_directory xcodebuild clean build
    Result
    FAILED
    Error:
    SwiftGeneratePch normal arm64 Compiling\ bridging\ header (in target ‘myApp’ from project ‘myApp’)

  2. bw-output
    I can successfully run command above but I get error after I ran sonar-scanner
    sonar-property
    sonar.cfamily.build-wrapper-output=bw-output
    Command
    build-wrapper-macosx-x86 --out-dir bw-output xcodebuild clean
    Result
    SUCCESS
    Sonar-scanner
    FAILED
    Error
    java.lang.IllegalStateException: java.nio.file.NoSuchFileException: /mypath/bw-output/build-wrapper-dump.json

My understanding is build-wrapper-dump.json will be generated at the end of the build. Is it correct?