Sonar scanner broken with iOS 15

Hello,
We are using Sonarqube version 8.9 LTS with sonar scanner for macosx version 4.6.2 (2021-05-07).
We are trying to run a SAST analysis on iOS source code.
It was working well with iOS 14.4 but now the scanner cannot analyse a file after the upgrade to iOS 15.

The error we get is the following:
05-Oct-2021 10:15:28 INFO: Requesting reproducer for: /Users/mobilebuild/bamboo-agent-home/xml-data/build-dir/NEXTMAJORMOBILE-CRELANMOBILEIOS-JOB1/classes/View/TableViewCells/TransactionCells/TransactionEditCell.m
05-Oct-2021 10:15:29 ERROR: Exception in thread pool-3-thread-1
05-Oct-2021 10:15:29 com.sonar.cpp.analyzer.Analyzer$AnalyzerException: Exit code != 0: /Users/mobilebuild/bamboo-agent-home/xml-data/build-dir/NEXTMAJORMOBILE-CRELANMOBILEIOS-JOB1/classes/View/TableViewCells/TransactionCells/TransactionEditCell.m
05-Oct-2021 10:15:29 at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:130)
05-Oct-2021 10:15:29 at com.sonar.cpp.analyzer.Subprocess.execute(Subprocess.java:50)
05-Oct-2021 10:15:29 at com.sonar.cpp.plugin.CFamilySensor.lambda$process$8(CFamilySensor.java:718)
05-Oct-2021 10:15:29 at com.sonar.cpp.analyzer.AnalysisExecutor.lambda$submit$0(AnalysisExecutor.java:59)
05-Oct-2021 10:15:29 at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source)
05-Oct-2021 10:15:29 at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
05-Oct-2021 10:15:29 at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
05-Oct-2021 10:15:29 at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
05-Oct-2021 10:15:29 at java.base/java.lang.Thread.run(Unknown Source)
05-Oct-2021 10:15:29
05-Oct-2021 10:15:29 ERROR:
05-Oct-2021 10:15:29 An error occurred while analyzing the following compilation unit:
05-Oct-2021 10:15:29 /Users/mobilebuild/bamboo-agent-home/xml-data/build-dir/NEXTMAJORMOBILE-CRELANMOBILEIOS-JOB1/classes/View/TableViewCells/TransactionCells/TransactionEditCell.m
05-Oct-2021 10:15:29 A file named “sonar-cfamily-reproducer.zip” has been generated to help the problem investigation.
05-Oct-2021 10:15:29 Please contact SonarSource support providing the following file to help improving the analyzer:
05-Oct-2021 10:15:29 /Users/mobilebuild/bamboo-agent-home/xml-data/build-dir/NEXTMAJORMOBILE-CRELANMOBILEIOS-JOB1/sonar-cfamily-reproducer.zip
05-Oct-2021 10:15:32 ERROR: Error during SonarScanner execution
05-Oct-2021 10:15:32 java.lang.IllegalStateException:
05-Oct-2021 10:15:32 An error occurred while analyzing the following compilation unit:
05-Oct-2021 10:15:32 /Users/mobilebuild/bamboo-agent-home/xml-data/build-dir/NEXTMAJORMOBILE-CRELANMOBILEIOS-JOB1/classes/View/TableViewCells/TransactionCells/TransactionEditCell.m
05-Oct-2021 10:15:32 A file named “sonar-cfamily-reproducer.zip” has been generated to help the problem investigation.
05-Oct-2021 10:15:32 Please contact SonarSource support providing the following file to help improving the analyzer:
05-Oct-2021 10:15:32 /Users/mobilebuild/bamboo-agent-home/xml-data/build-dir/NEXTMAJORMOBILE-CRELANMOBILEIOS-JOB1/sonar-cfamily-reproducer.zip
05-Oct-2021 10:15:32
05-Oct-2021 10:15:32 at com.sonar.cpp.plugin.CFamilySensor.process(CFamilySensor.java:396)
05-Oct-2021 10:15:32 at com.sonar.cpp.plugin.CFamilySensor.execute(CFamilySensor.java:175)
05-Oct-2021 10:15:32 at org.sonar.scanner.sensor.AbstractSensorWrapper.analyse(AbstractSensorWrapper.java:48)
05-Oct-2021 10:15:32 at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:85)
05-Oct-2021 10:15:32 at org.sonar.scanner.sensor.ModuleSensorsExecutor.execute(ModuleSensorsExecutor.java:62)
05-Oct-2021 10:15:32 at org.sonar.scanner.scan.ModuleScanContainer.doAfterStart(ModuleScanContainer.java:82)
05-Oct-2021 10:15:32 at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
05-Oct-2021 10:15:32 at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
05-Oct-2021 10:15:32 at org.sonar.scanner.scan.ProjectScanContainer.scan(ProjectScanContainer.java:392)
05-Oct-2021 10:15:32 at org.sonar.scanner.scan.ProjectScanContainer.scanRecursively(ProjectScanContainer.java:388)
05-Oct-2021 10:15:32 at org.sonar.scanner.scan.ProjectScanContainer.doAfterStart(ProjectScanContainer.java:357)
05-Oct-2021 10:15:32 at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
05-Oct-2021 10:15:32 at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
05-Oct-2021 10:15:32 at org.sonar.scanner.bootstrap.GlobalContainer.doAfterStart(GlobalContainer.java:150)
05-Oct-2021 10:15:32 at org.sonar.core.platform.ComponentContainer.startComponents(ComponentContainer.java:137)
05-Oct-2021 10:15:32 at org.sonar.core.platform.ComponentContainer.execute(ComponentContainer.java:123)
05-Oct-2021 10:15:32 at org.sonar.batch.bootstrapper.Batch.doExecute(Batch.java:72)
05-Oct-2021 10:15:32 at org.sonar.batch.bootstrapper.Batch.execute(Batch.java:66)
05-Oct-2021 10:15:32 at org.sonarsource.scanner.api.internal.batch.BatchIsolatedLauncher.execute(BatchIsolatedLauncher.java:46)
05-Oct-2021 10:15:32 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
05-Oct-2021 10:15:32 at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
05-Oct-2021 10:15:32 at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
05-Oct-2021 10:15:32 at java.base/java.lang.reflect.Method.invoke(Unknown Source)
05-Oct-2021 10:15:32 at org.sonarsource.scanner.api.internal.IsolatedLauncherProxy.invoke(IsolatedLauncherProxy.java:60)
05-Oct-2021 10:15:32 at com.sun.proxy.$Proxy0.execute(Unknown Source)
05-Oct-2021 10:15:32 at org.sonarsource.scanner.api.EmbeddedScanner.doExecute(EmbeddedScanner.java:189)
05-Oct-2021 10:15:32 at org.sonarsource.scanner.api.EmbeddedScanner.execute(EmbeddedScanner.java:138)
05-Oct-2021 10:15:32 at org.sonarsource.scanner.cli.Main.execute(Main.java:112)
05-Oct-2021 10:15:32 at org.sonarsource.scanner.cli.Main.execute(Main.java:75)
05-Oct-2021 10:15:32 at org.sonarsource.scanner.cli.Main.main(Main.java:61)
05-Oct-2021 10:15:32 ERROR:
05-Oct-2021 10:15:32 ERROR: Re-run SonarScanner using the -X switch to enable full debug logging.

Do you know what could possibly go wrong ?

Kind regards,
Lucas

Hi @macgeek ,

you are likely affected by CPP-3285, see this other topic:

Hello Massimo,

Thanks for your reply.
Does it require a new version of sonar scanner, the latest available version is from may of this year.
How fast can we expect to get a newer version ?

Is there a workaround that we can use until we are waiting for this new version to be released ?

Kind regards,
Lucas

Hi,

The following workaround solves the issue:
Append the following at the end of the build wrapper command: OTHER_CFLAGS="-DNS_FORMAT_ARGUMENT(A)"

Cheers,
Lucas

Hi @macgeek ,

thank you for sharing that and glad that you managed to fix the issue.

I’ve had a go at introducing this flag but it’s just causing build errors in my project:

/Developer/SDKs/iPhoneSimulator15.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSBundle.h:90:122: expected ';' after method prototype
- (NSString *)localizedStringForKey:(NSString *)key value:(nullable NSString *)value table:(nullable NSString *)tableName NS_FORMAT_ARGUMENT(1);

/Developer/SDKs/iPhoneSimulator15.0.sdk/System/Library/Frameworks/Foundation.framework/Headers/NSBundle.h:91:142: expected ';' after method prototype
- (NSAttributedString *)localizedAttributedStringForKey:(NSString *)key value:(nullable NSString *)value table:(nullable NSString *)tableName NS_FORMAT_ARGUMENT(1) NS_REFINED_FOR_SWIFT API_AVAILABLE(macos(12.0), ios(15.0), watchos(8.0), tvos(15.0));

/Developer/SDKs/iPhoneSimulator15.0.sdk/System/Library/Frameworks/UIKit.framework/Headers/UIKit.h:8:9: could not build module 'Foundation'
#import <Foundation/Foundation.h>

Is the fix released as part of 9.2 or something else I could try?

Hi @chrismash ,

it’s likely you haven’t properly set the flag leading to parsing error.

Yes, 9.2 should fix the issue, would you be able to try?

Thanks @mpaladin

I can look into trying 9.2, though I imagine it might require a server-side upgrade rather than something local to my project, which might not be super fast or straightforward (fairly big company all relying on sonar!)

Can you advise me on how to properly set the flag? I tried adding it to the end of the build wrapper command and got those errors, also got the same when adding it directly in xcode and just building the project so not sure what I’m doing wrong!