SonarCloud integration for iOS (Swift) project on Azure Pipeline

I have been tried to integrate SonarCloud to my iOS project repo in Azure DevOps. I have a pipeline setup to distribute builds for testing.

Now, I’m trying to integrate SonarCloud in pipeline. As per the documents, I have added connections to sonar cloud and did the basic setup.

YAML file contains this piece of code for SonarCloud reporting:

  # MARK: - SonarCloud
  - task: SonarCloudPrepare@1
    inputs:
      SonarCloud: 'XXXX' # Name of the SonarCloud service connection you created
      organization: 'XXXX'
      scannerMode: 'CLI'
      configMode: 'file'
  - task: Bash@3
    displayName: Download and install build wrapper
    inputs:
      targetType: 'inline'
      script: |
        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/
  - task: Bash@3
    displayName: Build in build-wrapper
    inputs:
      targetType: 'inline'
      workingDirectory:
      script: |
        export PATH=$HOME/.sonar/build-wrapper-macosx-x86:$PATH
        cd PatientAccess
        build-wrapper-macosx-x86 --out-dir build_wrapper_output_directory xcodebuild -workspace PatientAccess.xcworkspace -scheme PatientAccessDev test -destination 'platform=iOS Simulator,name=iPhone 14'
  - task: SonarCloudAnalyze@1

  # Publish Quality Gate Result task
  - task: SonarQubePublish@5
    inputs:
      pollingTimeoutSec: '300'

So with the above, I could able to run the build wrapper successfully. Strangely, facing issue during SonarCloudAnalyze@1 task.

This is the error I get:

2023-02-28T07:13:53.0852900Z 07:13:53.084 DEBUG: GET 200 https://sonarcloud.io/api/server/version | time=461ms
2023-02-28T07:13:53.0882140Z 07:13:53.087 DEBUG: Updated analysis started with a difference of -271 milliseconds
2023-02-28T07:13:53.1015450Z 07:13:53.101 DEBUG: Started at Tue Feb 28 07:13:48 UTC 2023
2023-02-28T07:13:53.1366470Z 07:13:53.136 INFO: Loaded core extensions: developer-scanner
2023-02-28T07:13:53.1586940Z 07:13:53.158 DEBUG: Installed core extension: com.sonarsource.branch.DeveloperScannerCoreExtension@327c7bea
2023-02-28T07:13:53.6818970Z 07:13:53.680 INFO: Found an active CI vendor: 'Azure DevOps'
2023-02-28T07:13:53.6922220Z 07:13:53.691 INFO: Load global settings
2023-02-28T07:13:54.1529410Z 07:13:54.152 DEBUG: GET 200 https://sonarcloud.io/api/settings/values.protobuf | time=461ms
2023-02-28T07:13:54.1556050Z 07:13:54.153 INFO: Load global settings (done) | time=462ms
2023-02-28T07:13:54.1615410Z 07:13:54.161 INFO: Process project properties
2023-02-28T07:13:54.1764990Z 07:13:54.176 INFO: ------------------------------------------------------------------------
2023-02-28T07:13:54.1766130Z 07:13:54.176 INFO: EXECUTION FAILURE
2023-02-28T07:13:54.1767170Z 07:13:54.176 INFO: ------------------------------------------------------------------------
2023-02-28T07:13:54.1767920Z 07:13:54.176 INFO: Total time: 10.940s
2023-02-28T07:13:54.2052680Z 07:13:54.204 INFO: Final Memory: 7M/30M
2023-02-28T07:13:54.2054600Z 07:13:54.204 INFO: ------------------------------------------------------------------------
2023-02-28T07:13:54.2132780Z ##[error]07:13:54.205 ERROR: Error during SonarScanner execution
2023-02-28T07:13:54.2158910Z ##[debug]Processed: ##vso[task.logissue type=error;]07:13:54.205 ERROR: Error during SonarScanner execution
2023-02-28T07:13:54.2160090Z 07:13:54.205 ERROR: Error during SonarScanner execution
2023-02-28T07:13:54.2162280Z ##[error]java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.ProjectLock
2023-02-28T07:13:54.2163530Z ##[debug]Processed: ##vso[task.logissue type=error;]java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.ProjectLock
2023-02-28T07:13:54.2164640Z java.lang.IllegalStateException: Unable to load component class org.sonar.scanner.scan.ProjectLock
2023-02-28T07:13:54.2166350Z ##[error]at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:52)
2023-02-28T07:13:54.2167780Z ##[debug]Processed: ##vso[task.logissue type=error;]at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:52)
2023-02-28T07:13:54.2169480Z 	at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:52)
2023-02-28T07:13:54.2173040Z ##[error]at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:678)
	at org.sonar.core.platform.ComponentContainer.getComponentByType(ComponentContainer.java:273)
	at org.sonar.scanner.scan.ProjectScanContainer.doBeforeStart(ProjectScanContainer.java:176)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:121)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
2023-02-28T07:13:54.2176090Z ##[debug]Processed: ##vso[task.logissue type=error;]at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:678)%0A	at org.sonar.core.platform.ComponentContainer.getComponentByType(ComponentContainer.java:273)%0A	at org.sonar.scanner.scan.ProjectScanContainer.doBeforeStart(ProjectScanContainer.java:176)%0A	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:121)%0A	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
2023-02-28T07:13:54.2178350Z 	at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:678)
2023-02-28T07:13:54.2179190Z 	at org.sonar.core.platform.ComponentContainer.getComponentByType(ComponentContainer.java:273)
2023-02-28T07:13:54.2180010Z 	at org.sonar.scanner.scan.ProjectScanContainer.doBeforeStart(ProjectScanContainer.java:176)
2023-02-28T07:13:54.2180830Z 	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:121)
2023-02-28T07:13:54.2239330Z ##[error]at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:130)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:58)
	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:52)
	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:566)
	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:126)
	at org.sonarsource.scanner.cli.Main.execute(Main.java:81)
	at org.sonarsource.scanner.cli.Main.main(Main.java:62)
Caused by: java.lang.IllegalStateException: Unable to load component class org.sonar.api.batch.fs.internal.DefaultInputProject
	at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:52)
	at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632)
	at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)
	at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)
	at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)
	at org.picocontainer.injectors.ConstructorInjector$CtorAndAdapters.getParameterArguments(ConstructorInjector.java:309)
	at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:335)
	at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
	at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
	at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
	at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
	at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
	at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)
	at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
	at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:50)
	... 22 more
Caused by: java.lang.IllegalStateException: Unable to load component class org.sonar.api.batch.bootstrap.ProjectReactor
	at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:52)
	at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632)
	at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)
	at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)
	at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)
	at org.picocontainer.injectors.SingleMemberInjector.getMemberArguments(SingleMemberInjector.java:61)
	at org.picocontainer.injectors.MethodInjector.getMemberArguments(MethodInjector.java:100)
	at org.picocontainer.injectors.MethodInjector$2.run(MethodInjector.java:112)
	at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
	at org.picocontainer.injectors.MethodInjector.decorateComponentInstance(MethodInjector.java:120)
	at org.picocontainer.injectors.CompositeInjector.decorateComponentInstance(CompositeInjector.java:58)
	at org.picocontainer.injectors.Reinjector.reinject(Reinjector.java:142)
	at org.picocontainer.injectors.ProviderAdapter.getComponentInstance(ProviderAdapter.java:96)
	at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)
	at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
	at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:50)
	... 36 more
Caused by: You must define the following mandatory properties for 'Unknown': sonar.projectKey
2023-02-28T07:13:54.2266810Z ##[debug]Processed: 	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)##vso[task.logissue type=error;]at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:130)%0A	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)%0A	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)%0A	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:58)%0A	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:52)%0A	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)%0A	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)%0A	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)%0A	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)%0A	at java.base/java.lang.reflect.Method.invoke(Method.java:566)%0A	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)%0A	at com.sun.proxy.$Proxy0.execute(Unknown Source)%0A	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)%0A	at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)%0A	at org.sonarsource.scanner.cli.Main.execute(Main.java:126)%0A	at org.sonarsource.scanner.cli.Main.execute(Main.java:81)%0A	at org.sonarsource.scanner.cli.Main.main(Main.java:62)%0ACaused by: java.lang.IllegalStateException: Unable to load component class org.sonar.api.batch.fs.internal.DefaultInputProject%0A	at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:52)%0A	at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632)%0A	at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)%0A	at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)%0A	at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)%0A	at org.picocontainer.injectors.ConstructorInjector$CtorAndAdapters.getParameterArguments(ConstructorInjector.java:309)%0A	at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:335)%0A	at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)%0A	at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)%0A	at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)%0A	at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)%0A	at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)%0A	at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)%0A	at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)%0A	at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:50)%0A	... 22 more%0ACaused by: java.lang.IllegalStateException: Unable to load component class org.sonar.api.batch.bootstrap.ProjectReactor%0A	at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:52)%0A	at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632)%0A	at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)%0A	at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)%0A	at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)%0A	at org.picocontainer.injectors.SingleMemberInjector.getMemberArguments(SingleMemberInjector.java:61)%0A	at org.picocontainer.injectors.MethodInjector.getMemberArguments(MethodInjector.java:100)%0A	at org.picocontainer.injectors.MethodInjector$2.run(MethodInjector.java:112)%0A	at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)%0A	at org.picocontainer.injectors.MethodInjector.decorateComponentInstance(MethodInjector.java:120)%0A	at org.picocontainer.injectors.CompositeInjector.decorateComponentInstance(CompositeInjector.java:58)%0A	at org.picocontainer.injectors.Reinjector.reinject(Reinjector.java:142)%0A	at org.picocontainer.injectors.ProviderAdapter.getComponentInstance(ProviderAdapter.java:96)%0A	at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)%0A	at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)%0A	at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:50)%0A	... 36 more%0ACaused by: You must define the following mandatory properties for 'Unknown': sonar.projectKey
2023-02-28T07:13:54.2281480Z 
2023-02-28T07:13:54.2282110Z 	at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:130)
2023-02-28T07:13:54.2282910Z 	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
2023-02-28T07:13:54.2283710Z 	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
2023-02-28T07:13:54.2284430Z 	at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:58)
2023-02-28T07:13:54.2285280Z 	at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:52)
2023-02-28T07:13:54.2286070Z 	at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
2023-02-28T07:13:54.2287180Z 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
2023-02-28T07:13:54.2288850Z 	at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
2023-02-28T07:13:54.2289830Z 	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
2023-02-28T07:13:54.2290610Z 	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
2023-02-28T07:13:54.2291360Z 	at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
2023-02-28T07:13:54.2292090Z 	at com.sun.proxy.$Proxy0.execute(Unknown Source)
2023-02-28T07:13:54.2292750Z 	at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
2023-02-28T07:13:54.2293500Z 	at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
2023-02-28T07:13:54.2294200Z 	at org.sonarsource.scanner.cli.Main.execute(Main.java:126)
2023-02-28T07:13:54.2294830Z 	at org.sonarsource.scanner.cli.Main.execute(Main.java:81)
2023-02-28T07:13:54.2295400Z 	at org.sonarsource.scanner.cli.Main.main(Main.java:62)
2023-02-28T07:13:54.2296160Z Caused by: java.lang.IllegalStateException: Unable to load component class org.sonar.api.batch.fs.internal.DefaultInputProject
2023-02-28T07:13:54.2297130Z 	at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:52)
2023-02-28T07:13:54.2298150Z 	at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632)
2023-02-28T07:13:54.2299050Z 	at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)
2023-02-28T07:13:54.2299950Z 	at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)
2023-02-28T07:13:54.2300790Z 	at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)
2023-02-28T07:13:54.2301670Z 	at org.picocontainer.injectors.ConstructorInjector$CtorAndAdapters.getParameterArguments(ConstructorInjector.java:309)
2023-02-28T07:13:54.2303020Z 	at org.picocontainer.injectors.ConstructorInjector$1.run(ConstructorInjector.java:335)
2023-02-28T07:13:54.2303880Z 	at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
2023-02-28T07:13:54.2304780Z 	at org.picocontainer.injectors.ConstructorInjector.getComponentInstance(ConstructorInjector.java:364)
2023-02-28T07:13:54.2305880Z 	at org.picocontainer.injectors.AbstractInjectionFactory$LifecycleAdapter.getComponentInstance(AbstractInjectionFactory.java:56)
2023-02-28T07:13:54.2306820Z 	at org.picocontainer.behaviors.AbstractBehavior.getComponentInstance(AbstractBehavior.java:64)
2023-02-28T07:13:54.2307600Z 	at org.picocontainer.behaviors.Stored.getComponentInstance(Stored.java:91)
2023-02-28T07:13:54.2308350Z 	at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)
2023-02-28T07:13:54.2309210Z 	at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
2023-02-28T07:13:54.2310120Z 	at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:50)
2023-02-28T07:13:54.2310820Z 	... 22 more
2023-02-28T07:13:54.2311440Z Caused by: java.lang.IllegalStateException: Unable to load component class org.sonar.api.batch.bootstrap.ProjectReactor
2023-02-28T07:13:54.2312330Z 	at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:52)
2023-02-28T07:13:54.2313190Z 	at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:632)
2023-02-28T07:13:54.2314010Z 	at org.picocontainer.parameters.BasicComponentParameter$1.resolveInstance(BasicComponentParameter.java:118)
2023-02-28T07:13:54.2314870Z 	at org.picocontainer.parameters.ComponentParameter$1.resolveInstance(ComponentParameter.java:136)
2023-02-28T07:13:54.2315700Z 	at org.picocontainer.injectors.SingleMemberInjector.getParameter(SingleMemberInjector.java:78)
2023-02-28T07:13:54.2316850Z 	at org.picocontainer.injectors.SingleMemberInjector.getMemberArguments(SingleMemberInjector.java:61)
2023-02-28T07:13:54.2317700Z 	at org.picocontainer.injectors.MethodInjector.getMemberArguments(MethodInjector.java:100)
2023-02-28T07:13:54.2318470Z 	at org.picocontainer.injectors.MethodInjector$2.run(MethodInjector.java:112)
2023-02-28T07:13:54.2319480Z 	at org.picocontainer.injectors.AbstractInjector$ThreadLocalCyclicDependencyGuard.observe(AbstractInjector.java:270)
2023-02-28T07:13:54.2320380Z 	at org.picocontainer.injectors.MethodInjector.decorateComponentInstance(MethodInjector.java:120)
2023-02-28T07:13:54.2321230Z 	at org.picocontainer.injectors.CompositeInjector.decorateComponentInstance(CompositeInjector.java:58)
2023-02-28T07:13:54.2322070Z 	at org.picocontainer.injectors.Reinjector.reinject(Reinjector.java:142)
2023-02-28T07:13:54.2322830Z 	at org.picocontainer.injectors.ProviderAdapter.getComponentInstance(ProviderAdapter.java:96)
2023-02-28T07:13:54.2323640Z 	at org.picocontainer.DefaultPicoContainer.getInstance(DefaultPicoContainer.java:699)
2023-02-28T07:13:54.2324430Z 	at org.picocontainer.DefaultPicoContainer.getComponent(DefaultPicoContainer.java:647)
2023-02-28T07:13:54.2325420Z 	at org.sonar.core.platform.ComponentContainer$ExtendedDefaultPicoContainer.getComponent(ComponentContainer.java:50)
2023-02-28T07:13:54.2326140Z 	... 36 more
2023-02-28T07:13:54.2327000Z Caused by: You must define the following mandatory properties for 'Unknown': sonar.projectKey
2023-02-28T07:13:55.5050650Z ##[debug]Exit code 1 received from tool '/Users/runner/work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.36.0/sonar-scanner/bin/sonar-scanner'
2023-02-28T07:13:55.5057080Z ##[debug]STDIO streams have closed for tool '/Users/runner/work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.36.0/sonar-scanner/bin/sonar-scanner'
2023-02-28T07:13:55.5118480Z ##[debug]task result: Failed
2023-02-28T07:13:55.5120970Z ##[error]The process '/Users/runner/work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.36.0/sonar-scanner/bin/sonar-scanner' failed with exit code 1
2023-02-28T07:13:55.5123520Z ##[debug]Processed: ##vso[task.issue type=error;]The process '/Users/runner/work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.36.0/sonar-scanner/bin/sonar-scanner' failed with exit code 1
2023-02-28T07:13:55.5127220Z ##[debug]Processed: ##vso[task.complete result=Failed;]The process '/Users/runner/work/_tasks/SonarCloudAnalyze_ce096e50-6155-4de8-8800-4221aaeed4a1/1.36.0/sonar-scanner/bin/sonar-scanner' failed with exit code 1
2023-02-28T07:13:55.5168110Z ##[section]Finishing: SonarCloudAnalyze

I could not get any help or related issue to fix. Googling didn’t help much. Mostly the similar issue reported are happening on Java project. Since I’m trying this on iOS(Swift) project, I have no clue what to do next.

Any help would be greatly appreciated. Thank you. :slight_smile:

Hey there.

You should also define the cliProjectKey, matching the project key for the project you want to analyze in SonarCloud.

This is the updated yml:

 # # MARK: - SonarCloud
  - task: SonarCloudPrepare@1
    inputs:
      SonarCloud: 'REDACTED' # Name of the SonarCloud service connection you created
      organization: 'REDACTED'
      scannerMode: 'CLI'
      configMode: 'file'
      cliProjectKey: 'REDACTED'
  - task: Bash@3
    displayName: Download and install build wrapper
    inputs:
      targetType: 'inline'
      script: |
        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/
  - task: Bash@3
    displayName: Build in build-wrapper
    inputs:
      targetType: 'inline'
      workingDirectory:
      script: |
        export PATH=$HOME/.sonar/build-wrapper-macosx-x86:$PATH
        cd XXX
        build-wrapper-macosx-x86 --out-dir build_wrapper_output_directory xcodebuild -workspace PatientAccess.xcworkspace -scheme PatientAccessDev test -destination 'platform=iOS Simulator,name=iPhone 14'
  - task: SonarCloudAnalyze@1
    inputs:
      SonarCloud: 'REDACTED' # Name of the SonarCloud service connection you created
      organization: 'REDACTED'
      cliProjectKey: 'REDACTED'

Anything else I’m missing? Still facing issue.

Are these your only three input to the SonarCloudAnalyze task or are there others?

just one more,

configMode: 'file'

Am I missing anything?

@Colin

This is the content of sonar-project.properties

sonar.projectName= REDACTED
sonar.host.url=https://sonarcloud.io
sonar.organization= REDACTED
sonar.projectKey= REDACTED
sonar.sourceEncoding=UTF-8
sonar.language=swift
sonar.cloud= REDACTED

sonar.swift.project= REDACTED.xcodeproj
sonar.sources=.

#sonar.coverageReportPaths=reports/sonarqube-generic-coverage.xml
#sonar.swift.coverage.reportPaths=reports/sonarqube-generic-coverage.xml
#sonar.swift.swiftLint.reportPaths=reports/swiftlint.json
sonar.cfamily.build-wrapper-output=build_wrapper_output_directory

# Ignoring C, C++
sonar.c.file.suffixes=-
sonar.cpp.file.suffixes=-
sonar.objc.file.suffixes=-



I wouldn’t suggest adding these via a sonar-project.properties file since they’re supposed to be added via the Azure DevOps task.

It looks like you’re missing several ones that come when you add the task in the UI wizard. For example, scannerMode is missing.

steps:
- task: SonarCloudPrepare@1
  inputs:
    SonarCloud: '$(sonarCloudEndpointName)'
    organization: '$(sonarCloudOrganization)'
    scannerMode: 'CLI'
    configMode: 'manual'
    cliProjectKey: '$(sonarCloudProjectKey)'
    cliProjectName: '$(sonarCloudProjectName)'
    cliProjectVersion: '1.0'
    cliSources: 'src'

Great the error which I was facing is now gone.

but getting a new error :frowning:


##[error]06:10:27.552 ERROR: Error during SonarScanner execution
java.lang.IllegalStateException: The "build-wrapper-dump.json" file was found but 0 C/C++/Objective-C files were analyzed. Please make sure that:
  * you are using the latest version of the build-wrapper and the CFamily analyzer
  * you are correctly invoking the scanner with correct configuration
  * your compiler is supported
  * you are wrapping your build correctly
  * you are wrapping a full/clean build
  * you are providing the path to the correct build-wrapper output directory
  * you are building and analyzing the same source checkout, absolute paths must be identical in build and analysis steps
	at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:582)
	at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:240)
	at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:62)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:75)
	at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:51)
	at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:64)
	at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:123)
	at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:109)
	at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:468)

@Colin
My codebase is in Swift and used the build wrapper from https://sonarcloud.io/static/cpp/build-wrapper-macosx-x86.zip

Why are you using the build wrapper if your code is all Swift? You only need to do this if you’re compiling/analyzing C/C++/Objective-C files.

@Colin

There is no documentation for Swift which I could find, all I found suggested using build-wrapper. Can you please direct me to documentation/material if there is any for Swift project?

Hey there.

You should be able to follow the documentation right in the SonarCloud UI when creating a project, or the documentation for the SonarScanner for Azure DevOps, there’s nothing you need to take care of when analyzing Swift. No build wrapper required.

hey colin
if in Azure i have set default branch as master so in long live branch it will Auto Scan master branch so for that do i have to change default branch as desire branch in Azure branch setting ?