Is there a way to get the build wrapper to work on a Mac M2 machine?

Must-share information (formatted with Markdown):

  • which versions are you using
    SonarQube: Developer Edition - Version 8.9.3
    Build wrapper: build-wrapper-macosx-x86
    Scanner: sonar-scanner-
  • how is SonarQube deployed: zip
  • what are you trying to achieve
    Execute the SonarQube analyze in Mac M2 machine.
  • what have you tried so far to achieve this
    I have installed the SonarQube ‘Build Wrapper’ on the Mac M2 machine and attempted to run the build wrapper using both Terminal and PowerShell. However, I am encountering an issue where the ‘build-wrapper-dump.json’ file is empty.

Issue: I am experiencing difficulties while attempting to execute the build wrapper on a Mac M2 chip machine. The execution is not proceeding as expected.

Documentation: Upon reviewing the SonarQube documentation, I did not find any specific mention of support for the Mac M2 machine in the context of the build wrapper.

Question: Given that we are using the Developer Edition of SonarQube, is there a way to get the build wrapper to work on a Mac M2 machine? Alternatively, are there any other methods to run it?

Hi @DivyaMariappan, and welcome to our community!

You are using an extremely old unsupported version of SonarQube. Mac M1 did not exist back then.
You are missing a lot of great features in general and for C++ in particular.
I highly recommend upgrading.

As for what you are asking for about the build-wrapper, it’s been available since SonarQube 10.2


Thank you for your guidance, Geoffray.

I intend to utilize SonarQube 10.2 for my upcoming tasks. Could you please confirm if this version is compatible with the Mac M2 architecture?

I can confirm that SonarQube 10.2 and beyond work with macOS and Apple Silicon chips (M1, M2, M3).

As you consider moving to a more up-to-date version of SonarQube, the current version is 10.4, and 10.5 should be released around the end of next week.
You can also consider upgrading your scanner.

There have been a few significant changes since 8.9. It might be worth considering these two points:

  • The issues’ types and severity have been reworked under the umbrella of our Clean Code concept. You can have an overview here.
  • As you are focusing on C and C++, the dedicated help page could be an interesting read mentioning multiple features that appeared.

Hello Geoffray,

I trust this message finds you well. I apologize for the delay in my response.

We have recently updated SonarQube version 10.2, however, our issue remains unresolved. We are currently working on an Objective-C project that is being built on a macOS machine. Unfortunately, we are unable to perform SonarQube analysis due to the lack of support for M2 macOS machines by BuildWrapper, as referenced in the documentation.

We attempted to utilize the ‘Compilation Database’ as a workaround, but our projects are not built using ‘CMAKE’.

Could you kindly provide an alternative method for conducting SonarQube analysis for our Objective-C project that is being built on an M2 macOS machine?

Thank you,

Any updates?

Hi @DivyaMariappan ,

what problem are you facing with the build-wrapper?

Just in case, you may consider using SonarQube 10.5.

You can generate a compilation database directly from xcode with the following recipe.

Use Clang compiler feature to generate partial compilation database files and aggregate them. You need to set -gen-cdb-fragment-path on OTHER_CFLAGS of xcodebuild command line:

# add to your xcodebuild command: OTHER_CFLAGS="\$(inherited) -gen-cdb-fragment-path \$(PROJECT_DIR)/CompilationDatabase"
xcodebuild clean build arg1 .. argN OTHER_CFLAGS="\$(inherited) -gen-cdb-fragment-path \$(PROJECT_DIR)/CompilationDatabase"
pushd CompilationDatabase
sed -e '1s/^/[\'$'\n''/' -e '$s/,$/\'$'\n'']/' *.json > ../compile_commands.json

Then pass the new property to sonar-scanner:

sonar-scanner ... -Dsonar.cfamily.compile-commands= compile_commands.json ...
1 Like