Issue analyzing swift objective-c Project

Must-share information (formatted with Markdown):

  • which versions are you using (SonarQube, Scanner, Plugin, and any relevant extension)
    SonarQube Developer Edition v9.0.1, build-wrapper version 6.23 (macosx-x86)

  • what are you trying to achieve
    Analyze iOS project with Swift, Obj-C within Jenkins using sonarqube Build Wrapper 6.23 and SonarQube Scanner for Jenkins 2.13.1

  • what have you tried so far to achieve this

Build Wrapper

    build-wrapper-macosx-x86 --out-dir DerivedData/compilation-database \
        xcodebuild \
                -scheme App \
                -derivedDataPath DerivedData \
				-workspace App.xcworkspace \
				-configuration Debug \
                clean build

Execute sonarqube scanner

     sonar.projectKey=App
     sonar.projectName=App
     sonar.projectVersion=1.0
     sonar.sources=App
     sonar.cfamily.build-wrapper-output=$WORKSPACE/DerivedData/compilation-database
     sonar.sourceEncoding=UTF-8
     sonar.cfamily.threads=4
     sonar.cfamily.cache.enabled=false

While running an analyzes on a Jenkins agent (Mac) the build wrapper and build executes ok but when the sonar scanner analyzes the project if fails with the below errors:

11:23:42.762 ERROR: Exception in thread pool-3-thread-2
com.sonar.cpp.analyzer.Analyzer$AnalyzerException: Exit code != 0: /Users/Shared/Jenkins/workspace/App/src/Utilities.m
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:132)
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:52)
	at com.sonar.cpp.plugin.CFamilySensor.lambda$process$12(CFamilySensor.java:700)
	at com.sonar.cpp.analyzer.AnalysisExecutor.lambda$submit$0(AnalysisExecutor.java:59)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)

11:23:42.762 ERROR: Exception in thread pool-3-thread-3
com.sonar.cpp.analyzer.Analyzer$AnalyzerException: Exit code != 0: /Users/Shared/Jenkins/workspace/App/src/ViewControllers/head.m
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:132)
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:52)
	at com.sonar.cpp.plugin.CFamilySensor.lambda$process$12(CFamilySensor.java:700)
	at com.sonar.cpp.analyzer.AnalysisExecutor.lambda$submit$0(AnalysisExecutor.java:59)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)

Mac agent details:

  ProductName:    Mac OS X
  ProductVersion: 10.15.7
  BuildVersion:   19H15

Note

When doing the same procedure on Azure DevOps the same Errors are thrown:

ERROR: file '/Users/runner/work/1/s/DerivedData/Build/ProductsTemplate.h' has been modified since the precompiled header '/Users/runner/work/1/s/.scannerwork/.sonartmp/10438520029609876548/995B4822C510C166D4D82BB63D70BA4AE0A97825.pch' was built: mtime changed

ERROR: file '/Users/runner/work/1/s/DerivedData/Build/ProductsTemplate.h' has been modified since the precompiled header '/Users/runner/work/1/s/.scannerwork/.sonartmp/10438520029609876548/995B4822C510C166D4D82BB63D70BA4AE0A97825.pch' was built: mtime changed

ERROR: file '/Users/runner/work/1/s/DerivedData/Build/ProductsTemplate.h' has been modified since the precompiled header '/Users/runner/work/1/s/.scannerwork/.sonartmp/10438520029609876548/995B4822C510C166D4D82BB63D70BA4AE0A97825.pch' was built: mtime changed


##[error]ERROR: Exception in thread pool-3-thread-3
com.sonar.cpp.analyzer.Analyzer$AnalyzerException: Exit code != 0: /Users/runner/work/1/s/App/Manager.m
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:132)
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:52)
	at com.sonar.cpp.plugin.CFamilySensor.lambda$process$12(CFamilySensor.java:700)
	at com.sonar.cpp.analyzer.AnalysisExecutor.lambda$submit$0(AnalysisExecutor.java:59)
	at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
	at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:829)

ERROR: Exception in thread pool-3-thread-4
com.sonar.cpp.analyzer.Analyzer$AnalyzerException: Exit code != 0: /Users/runner/work/1/s/App/...
ERROR: Exception in thread pool-3-thread-3
com.sonar.cpp.analyzer.Analyzer$AnalyzerException: Exit code != 0: /Users/runner/work/1/s/App/1Manager.m
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:132)
	at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:52)
	at com.sonar.cpp.plugin.CFamilySensor.lambda$process$12(CFamilySensor.java:700)
	at com.sonar.cpp.analyzer.AnalysisExecutor.lambda$submit$0(AnalysisExecutor.java:59)

Hi @Darren13579 ,

are the logs telling you to share a file called sonar-cfamily-reproducer with us?

Hi @mpaladin,

Yes, i have a copy here. I can private share it with you

Hi @Darren13579 ,

the cause of the issue is that we currently don’t properly set up the analyzer to align with the build configuration. I created a ticket to track the issue: https://jira.sonarsource.com/browse/CPP-3276.

1 Like

Thank you Massimo for looking into this.

A post was split to a new topic: Error analyzing Objective-C file

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