SonarQube setup

Lidiomar Fernando
2 min readSep 10, 2023

--

It is a quick step-by-step presenting how to setup the Sonaqube, running locally.

Dowloads

Sonarqube: https://www.sonarsource.com/products/sonarqube/downloads

SonarScan: https://docs.sonarsource.com/sonarqube/latest/analyzing-source-code/scanners/sonarscanner/

Java version 17: https://www.oracle.com/java/technologies/javase/jdk17-archive-downloads.html

Steps

Sonarqube setup:

  • Install Java 17.
  • Unzip the Sonarqube .zip file and execute the command in the terminal: sh <SonarQubeDirectory>/SonarQube/bin/macosx-universal-64/sonar.sh console
  • After run the .sh the Sonarqube it will be available locally in the address http://localhost:9000/

Xcode project setup:

Add code coverage for the project target.

Sonar scanner setup:

Add the sonar setting to the ~/bash_profile file:

# Sonar Setting
export PATH=$PATH:/Applications/SonarScanner/bin
export PATH=$PATH:/Applications/SonarQube/bin

Create the sonar-project.properties file in root folder of the project. Add the follow configuration into the file:

# Sonar Server details

sonar.host.url=http://localhost:9000

sonar.login=admin

sonar.password=admin@123

sonar.projectKey=ProjectTest

sonar.sources=.

sonar.sourceEncoding=UTF-8

sonar.swift.project=ProjectTest.xcodeproj

sonar.swift.appScheme=ProjectTest

sonar.swift.simulator=platform=iOS Simulator,name=iPhone 14 Pro,OS=16.1

sonar.exclusions=**/*.xml,Pods/**/*,Reports/**/*

sonar.inclusions=*.swift

Run the sonar scanner in the project folder: sh ~/<SonarScannerFolder>/SonarScanner/bin/sonar-scanner

If some authentication error happen, it can be solved disabling the "Force user authentication" option in the administration section of the SonarQube:

--

--

Lidiomar Fernando
Lidiomar Fernando

Written by Lidiomar Fernando

I’m a software developer. I work as mobile native developer for Android and iOS.

No responses yet