Unable to integrated SonarQube in XCode Objetive C version in Mac OS

Hi,

I followed below steps:

  1. Downloaded the SonarQube & SonarQube Scanner and moved this folders into Application Folder in my Mac OSx
  2. Downloaded SonarQube Sonar-Objective-C plug in and moved in to Sonar plugins folder
  3. Then started the sonar console
  4. created our XCode Project and integrated pods
  5. Downloaded and updated the sonar-properties files and moved into our XCode Project Structure
  6. Downloaded and updated the sonar-script file for objective-c and moved into XCode Project structure
  7. Updated the XCode project target settings to gather project code coverage for all targets
  8. After this run the sonar-scrit.sh for objective c
  9. then its running and showing error like

ERROR - Command ‘xctool -workspace TestDemoSonarQube.xcworkspace -sdk iphonesimulator ARCHS=i386 VALID_ARCHS=i386 CURRENT_ARCH=i386 ONLY_ACTIVE_ARCH=NO -scheme TestDemoSonarQube clean’ failed with error code: 4

Kindly help us…

Hi @narendarsonar,

a little bit more of context or log output would be nice.

What version of build-wrapper are you using? Could you make sure its version is 6.6?

jvm 1 | Wrapper (Version 3.2.3) http://wrapper.tanukisoftware.org

How to update build-wrapper version
Can you please help me

How to update build-wrapper version
Can you please help me

Hi @narendarsonar,

please take the time to read the documentation: https://docs.sonarqube.org/latest/analysis/languages/cfamily/

After making changes,
Project execution success
and project created in sonar server localhost:9000
project showing, but showing erroe message like:
The main branch has no lines of code.

Hi @narendarsonar,

could you please share the logs of the sonar-scanner?

Hi

narendar.n@Narendar-MacBook-Pro TestDemoSonarQube % sonar-scanner

INFO: Scanner configuration file: /usr/local/Cellar/sonar-scanner/4.2.0.1873/libexec/conf/sonar-scanner.properties

INFO: Project root configuration file: /Users/narendar.n/Desktop/TestDemoSonarQube/sonar-project.properties

INFO: SonarQube Scanner 4.2.0.1873

INFO: Java 13.0.2 Oracle Corporation (64-bit)

INFO: Mac OS X 10.15.2 x86_64

INFO: User cache: /Users/narendar.n/.sonar/cache

INFO: SonarQube server 8.1.0

INFO: Default locale: “en_GB”, source code encoding: “UTF-8”

INFO: Load global settings

INFO: Load global settings (done) | time=296ms

INFO: Server id: BF41A1F2-AXAZpPiHTc3iKUoIVzwU

INFO: User cache: /Users/narendar.n/.sonar/cache

INFO: Load/download plugins

INFO: Load plugins index

INFO: Load plugins index (done) | time=272ms

INFO: Load/download plugins (done) | time=373ms

INFO: Process project properties

INFO: Process project properties (done) | time=6ms

INFO: Execute project builders

INFO: Execute project builders (done) | time=3ms

INFO: Project key: TestDemoSonarQube

INFO: Base dir: /Users/narendar.n/Desktop/TestDemoSonarQube

INFO: Working dir: /Users/narendar.n/Desktop/TestDemoSonarQube/.scannerwork

INFO: Load project settings for component key: ‘TestDemoSonarQube’

INFO: Load quality profiles

INFO: Load quality profiles (done) | time=517ms

INFO: Load active rules

INFO: Load active rules (done) | time=4459ms

INFO: Indexing files…

INFO: Project configuration:

INFO: Excluded sources: /*.xml, Pods//, Reports/**/, *.objectivec

INFO: Included tests: *.objectivec

INFO: 10 files indexed

INFO: 0 files ignored because of inclusion/exclusion patterns

INFO: 0 files ignored because of scm ignore settings

INFO: ------------- Run sensors on module TestDemoSonarQube

INFO: Load metrics repository

INFO: Load metrics repository (done) | time=253ms

WARNING: An illegal reflective access operation has occurred

WARNING: Illegal reflective access by net.sf.cglib.core.ReflectUtils$1 (file:/Users/narendar.n/.sonar/cache/a2b6a8802525720c8af2ca4fa85a2513/sonar-javascript-plugin.jar) to method java.lang.ClassLoader.defineClass(java.lang.String,byte,int,int,java.security.ProtectionDomain)

WARNING: Please consider reporting this to the maintainers of net.sf.cglib.core.ReflectUtils$1

WARNING: Use --illegal-access=warn to enable warnings of further illegal reflective access operations

WARNING: All illegal access operations will be denied in a future release

INFO: Sensor JaCoCo XML Report Importer [jacoco]

INFO: Sensor JaCoCo XML Report Importer [jacoco] (done) | time=2ms

INFO: Sensor JavaXmlSensor [java]

INFO: Sensor JavaXmlSensor [java] (done) | time=1ms

INFO: Sensor HTML [web]

INFO: Sensor HTML [web] (done) | time=2ms

INFO: ------------- Run sensors on project

INFO: Sensor Zero Coverage Sensor

INFO: Sensor Zero Coverage Sensor (done) | time=1ms

INFO: CPD Executor Calculating CPD for 0 files

INFO: CPD Executor CPD calculation finished (done) | time=0ms

INFO: Analysis report generated in 58ms, dir size=76 KB

INFO: Analysis report compressed in 11ms, zip size=10 KB

INFO: Analysis report uploaded in 483ms

INFO: ANALYSIS SUCCESSFUL, you can browse http://localhost:9000/dashboard?id=TestDemoSonarQube

INFO: Note that you will be able to access the updated dashboard once the server has processed the submitted analysis report

INFO: More about the report processing at http://localhost:9000/api/ce/task?id=AXAe7XgE7JWzCvUETwfR

INFO: Analysis total time: 7.673 s

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

INFO: EXECUTION SUCCESS

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

INFO: Total time: 9.020s

INFO: Final Memory: 12M/47M

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

I shared the sonar-console logs

Can you please help me

Hi @narendarsonar,

I don’t know your configuration but no files are indexed and/or analyzed, please review your configuration and share it if you cannot spot the issue.

Hi

I followed sonar-project.properites file contains

Sonar Server details

sonar.host.url=http://localhost:9000
sonar.login=admin
sonar.password=admin

Project Details

sonar.projectKey=com.company.appSampleSwift
sonar.projectName=SampleSwiftDemo
sonar.projectDescription=This is the Sonar demo application for the code quality check

Comment if you have a project with mixed ObjC / Swift

sonar.language=swift

Path to source directories

sonar.sources=SampleSwiftDemo,SampleSwiftDemoTests,SampleSwiftDemoUITests

sonar.sources=.

Exclude directories

sonar.test.inclusions=/Test/
sonar.test.inclusions=.swift
sonar.exclusions=**/
.xml,Pods//*,Reports//*

sonar.inclusions=*.swift

Path to test directories (comment if no test)

sonar.tests=SampleSwiftDemoTests,SampleSwiftDemoUITests

Destination Simulator to run surefire

As string expected in destination argument of xcodebuild command

Example = sonar.swift.simulator=platform=iOS Simulator,name=iPhone 6,OS=9.2

sonar.swift.simulator=platform=iOS Simulator,name=iPhone 7,OS=12.0

sonar.swift.simulator=platform=iOS Simulator,name=iPhone 7,OS=12.1

Xcode project configuration (.xcodeproj)

and use the later to specify which project(s) to include in the analysis (comma separated list)

Specify either xcodeproj or xcodeproj + xcworkspace

sonar.swift.project=SampleSwiftDemo.xcodeproj
sonar.swift.workspace=SampleSwiftDemo.xcworkspace

Specify your appname.

This will be something like “myApp”

Use when basename is different from targeted scheme.

Or when slather fails with ‘No product binary found’

sonar.swift.appName=SampleSwiftDemo

Scheme to build your application

sonar.swift.appScheme=SampleSwiftDemo

Configuration to use for your scheme. if you do not specify that the default will be Debug

sonar.swift.appConfiguration=Debug

##########################

Optional configuration

##########################

Encoding of the source code

sonar.sourceEncoding=UTF-8

SCM

sonar.scm.enabled=true

sonar.scm.url=scm:git:http://xxx

JUnit report generated by run-sonar.sh is stored in sonar-reports/TEST-report.xml

Change it only if you generate the file on your own

The XML files have to be prefixed by TEST- otherwise they are not processed

sonar.junit.reportsPath=sonar-reports/TEST-report.xml

Cobertura report generated by run-sonar.sh is stored in sonar-reports/coverage-swift.xml

Change it only if you generate the file on your own

sonar.swift.coverage.reportPattern=sonar-reports/coverage-swift*.xml
#sonar.swift.coverage.reportPattern=sonar-reports/cobertura.xml

OCLint report generated by run-sonar.sh is stored in sonar-reports/oclint.xml

Change it only if you generate the file on your own

sonar.swift.swiftlint.report=sonar-reports/*swiftlint.txt

Change it only if you generate the file on your own

sonar.swift.tailor.report=sonar-reports/*tailor.txt

Paths to exclude from coverage report (surefire, 3rd party libraries etc.)

sonar.swift.excludedPathsFromCoverage=pattern1,pattern2

sonar.swift.excludedPathsFromCoverage=.Tests.,

##########################

Tailor configuration

##########################

Tailor configuration

-l,–max-line-length=<0-999> maximum Line length (in characters)

–list-files display Swift source files to be analyzed

–max-class-length=<0-999> maximum Class length (in lines)

–max-closure-length=<0-999> maximum Closure length (in lines)

–max-file-length=<0-999> maximum File length (in lines)

–max-function-length=<0-999> maximum Function length (in lines)

–max-name-length=<0-999> maximum Identifier name length (in characters)

–max-severity=<error|warning (default)> maximum severity

–max-struct-length=<0-999> maximum Struct length (in lines)

–min-name-length=<1-999> minimum Identifier name length (in characters)

sonar.swift.tailor.config=–no-color --max-line-length=100 --max-file-length=500 --max-name-length=40 --max-name-length=40 --min-name-length=4

=========================
Can you please confirm one thing,

For iOS Objective - C,
whether we require the Sonar Developer version or Community version.?

Hi @narendarsonar,

it seems like you are not using SonarSource official plugin, you are using swiftlint with a messy configuration, please refer to their support channel if you wish to use their plugin.

To analyze Swift and Objective-C with official SonarSource plugins you need Developer edition.

2 posts were split to a new topic: Build-wrapper failing xctool build

A post was merged into an existing topic: Build-wrapper failing xctool build