Build Failed using Sonar Cloud scan for iOS app with Azure DevOps pipeline

Hi,
I am facing an error which I have attached in screenshot. Below is my yml file configuration.

jobs:
- job: BuildMacOSWithSonarCloud
  displayName: Build for MacOS\XCode With SonarCloud
  pool:
    vmImage: 'macos-latest'
  variables:
    BUILD_WRAPPER_DOWNLOAD_URL: https://sonarcloud.io/static/cpp/build-wrapper-macosx-x86.zip
  steps:
  - task: SonarCloudPrepare@1
    inputs:
      SonarCloud: 'myconnection' # Name of the SonarCloud service connection you created
      organization: 'xyz'
      scannerMode: 'CLI'
      configMode: 'file'
  - bash: |
      mkdir -p $HOME/.sonar
      curl -sSLo $HOME/.sonar/build-wrapper-macosx-x86.zip ${{variables.BUILD_WRAPPER_DOWNLOAD_URL}}
      unzip -o $HOME/.sonar/build-wrapper-macosx-x86.zip -d $HOME/.sonar/
    displayName: Download and install build wrapper
  - bash: |
      export PATH=$HOME/.sonar/build-wrapper-macosx-x86:$PATH
      build-wrapper-macosx-x86 --out-dir build_wrapper_output_directory xcodebuild
    workingDirectory: .
    displayName: Build in build-wrapper
  - task: SonarCloudAnalyze@1

Error
##[error]Bash exited with code ‘65’.
Finishing: Build in build-wrapper

Hi,

Welcome to the community!

Could you provide the text of your logs, starting with maybe the ‘Build in Build-wrapper’ step?

 
Thx,
Ann

Hello Ann,

Thanks for your reply. Did you mean this below text?

  1. /Users/runner/.sonar/build-wrapper-macosx-x86/libinterceptor.dylib: code signature in (/Users/runner/.sonar/build-wrapper-macosx-x86/libinterceptor.dylib) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.

Command line invocation:

/Applications/Xcode_13.2.1.app/Contents/Developer/usr/bin/xcodebuild

User defaults from command line:

IDEPackageSupportUseBuiltinSCM = YES

dyld: warning: could not load inserted library ‘/Users/runner/.sonar/build-wrapper-macosx-x86/libinterceptor.dylib’ into hardened process because no suitable image found. Did find:

/Users/runner/.sonar/build-wrapper-macosx-x86/libinterceptor.dylib: code signature in (/Users/runner/.sonar/build-wrapper-macosx-x86/libinterceptor.dylib) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.

/Users/runner/.sonar/build-wrapper-macosx-x86/libinterceptor.dylib: stat() failed with errno=1

note: Using new build system

note: Planning

Analyze workspace

Create build description

Build description signature: a4966adb37a61d2809f0acbc63f0a022

Build description path: /Users/runner/work/1/s/build/XCBuildData/a4966adb37a61d2809f0acbc63f0a022-desc.xcbuild

note: Build preparation complete

note: Building targets in dependency order

2.* BUILD FAILED **

##[error]Bash exited with code ‘65’.

Finishing: Build in build-wrapper

Hi,

Is that really all you get? Also, I’m realizing you tagged this with swift. Are you analyzing a Swift project? Because you don’t need the build-wrapper for that.

 
Ann

1 Like

Yes, I am analysing swift project.
Can you please share sample code without build wrapper to test?

Hi,

Did you use the project import wizard? It should have given you this. It’s just a simple analysis, without the build-wrapper.

 
Ann

Hi,
Yes I used import wizard and the configuration written above including build wrapper was part of that.

Hi,

Does your project also contain C, C++ or Objective-C? Could you describe the path you took through the tutorial? Because I’ve just gone through the tutorial for a Swift project and I don’t get anything about the build-wrapper.

 
Ann

Hi,
Yes there are third party frameworks(Objective-C) used in swift project.
Below is the tutorial link for a sample project.

Hi,

Do you want/need to analyze those frameworks? Normally we advise excluding 3rd-party code from analysis…

 
Ann

Hi,
I added those framework in git-ignore. Means not analysing those frameworks but still facing same issue. Also the tutorial link I shared above have configuration for swift project including build-wrapper. Can you please suggest/share configuration for swift project without wrappper.

Yasir

Hi Yasir,

For analyzing without the build-wrapper, you just… analyze without it. Strip out all the build-wrapper stuff and just run the analysis.

Does that help?

 
Ann

Hi Ann,
After stripping out all the build-wrappper stuff and updating sonar-project.properties file, I am facing this issue,

FO: CFamily plugin version: 6.36.0.52033
INFO: Using build-wrapper output: /Users/runner/work/1/s/build_wrapper_output_directory/build-wrapper-dump.json
INFO: Available processors: 3
INFO: Using 3 threads for analysis.
WARN: 
CFamily plugin supports incremental analysis with the use of a cache:

* if you do not want to enable cache
  please explicitly disable it
  by setting the following property to your analysis:
  sonar.cfamily.cache.enabled=false

* to enable cache please specify the following 2 options:
  sonar.cfamily.cache.enabled=true
  sonar.cfamily.cache.path=relative_or_absolute_path_to_cache_location

* visit the documentation page for more information
  https://docs.sonarcloud.io/advanced-setup/languages/c-c-objective-c/

INFO: ------------------------------------------------------------------------
INFO: EXECUTION FAILURE
INFO: ------------------------------------------------------------------------
INFO: Total time: 59.124s
INFO: Final Memory: 70M/237M
INFO: ------------------------------------------------------------------------
##[error]ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: java.nio.file.NoSuchFileException: /Users/runner/work/1/s/build_wrapper_output_directory/build-wrapper-dump.json
	at com.sonar.cpp.plugin.BuildWrapperJsonReader.readCaptures(BuildWrapperJsonReader.java:90)
	at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:781)

Hi,

Did you also remove the parameter specifying the build-wrapper file location?

 
Ann

Hi,
Yes, I removed that too.

Hi,

It looks like C++ files are still being detected in the project. I’m not sure at what level a .gitignore exclusion kicks in. Can you explicitly exclude them, using a **/*.cpp (or whatever the relevant extensions is) pattern?

 
Ann

1 Like

Hi Ann,
Thank you very much for your guidance to successfully analyse my swift project which was due in my bucket for very long time.
By adding below links in sonar-properties file, I am able to analyse project successfully.

sonar.c.file.suffixes=-
sonar.cpp.file.suffixes=-
sonar.objc.file.suffixes=-

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.