Not able to integrate sonar cloud using terminal/CLI for Swift Code Scan

i m trying to integrate sonarCloud but not able to scan my swift code help me out, using macos ERROR: SonarQube server [http://localhost:9000] can not be reached

INFO: ------------------------------------------------------------------------

INFO: EXECUTION FAILURE

INFO: ------------------------------------------------------------------------

INFO: Total time: 0.464s

INFO: Final Memory: 3M/17M

INFO: ------------------------------------------------------------------------

ERROR: Error during SonarScanner execution

org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarScanner analysis

Hey there.

What command are you running to execute the analysis, and what configuration have you provided?

At the very least, it doesn’t look like sonar.host.url has been set to https://sonarcloud.io.

check attachment SS
this key i have set in sonar-scanner.properties , i have tried manually setup select macos also tried objectiveC command but getting error like ,below
15:45:53.928 ERROR: Error during SonarScanner execution,
org.sonarsource.scanner.api.internal.ScannerException: Unable to execute SonarScanner analysis

also getting error on buildwrapper command : The following build commands failed:
** SwiftGeneratePch normal arm64 Compiling\ bridging\ header (in target ‘ShowMeScreenShare’ from project ‘ShowMeByBlitzz’)**

i also getting this error
ERROR: Project not found. Please check the ‘sonar.projectKey’ and ‘sonar.organization’ properties, the ‘SONAR_TOKEN’ environment variable, or contact the project administrator

i have checked all the keyvalue are correct

also i ran command mention in attachment


Hey there.

First, let me suggest you get rid of everything in sonar-scanner.properties and focus on only passing configuration through the commands specified in the UI tutorials.

Second – can you clarify what language(s) you are trying to analyze? Only Swift code, or some C/C++/Objective-C as well?

only swift code but in my swift code there is objective c library i m using via bridging header.

Okay. In that case, forget about the build wrapper and make sure you’ve configured sonar.c.file.suffixes=- (also for cpp and objc) as you were in the screenshot above (but don’t do this in a sonar-scanner.properties file).

If you’re still receiving this error:

I suggest posting your analysis logs in full, so it’s clear at what stage of the analysis the issue is being raised.

ok removed sonar.c.file.suffixes=- from sonar Properties and
Terminal Saved Output Log Sonar.txt (11.1 KB)

You do need to set sonar.c.file.suffixes=- (and the others), but I’m suggesting not to do so in the sonar-scanner.properties file

hi colin sonar setup is done but showing Master branch how can i add another branch local development branch because i m doing my changes in dev branch please guide me accordingly. for iOS swift code

Take a look at the documentation on branch analysis setup.

hi colin
checked this doc in this below description where i have to set this two parameter in environ variable or sonar property list ? also check attachment renaming branch with current branch name it will auto analys branch that we want to be analys?
using this command sonar-scanner
-Dsonar.organization=blitzz-organization
-Dsonar.projectKey=Blitzz_ShowMe_iOS
-Dsonar.sources=.
-Dsonar.host.url=https://sonarcloud.io
-Dsonar.branch.name=Task_22433_SonarQubeSetup

Note: using terminal for setup manually

Under the hood

Internally, when the SonarScanner performs a branch analysis in an integrated CI, it automatically sets two analysis parameters:

Hey there.

I’m really not sure what you’re asking – can you try using different words?

How do i change default Master branch to Another branch? which steps i have to follow where to mention branch parameter? using terminal for Sonar scan for Swift projecr

  • Starting in SonarQube v10.2 you can set another branch to be the main branch
  • Your only option in versions before that (or in SonarCloud) is to rename the existing branch (or start over from a new project and configure the branch name on project creation)

i m using sonarCloud, so i can just rename branch name which i want it will work ?

Hello Colin
i have recreate Project can you guide me where to mention branch name ?
in sonar properti file or in command line like below
sonar-scanner
-Dsonar.organization=XXX
-Dsonar.projectKey=XXX
-Dsonar.sources=.
-Dsonar.host.url=https://sonarcloud.io