- ALM used (Azure DevOps)
- CI system used (Azure DevOps
- Languages of the repository (swift and objective c)
Welcome to the community!
You haven’t given us a lot to go on here. Can you provide some details about what you’ve tried?
Repository has both swift and objective c files. Able to generate coverage for swift files. whereas not able to find the same for objective c files.
these are the sonar properties which we have in the build template configured:
extraProperties: | sonar.c.file.suffixes=- sonar.sourceEncoding=UTF-8 sonar.cpp.file.suffixes=- sonar.objc.file.suffixes=- sonar.cfamily.cache.enabled=false sonar.cfamily.build-wrapper-output=false sonar.cfamily.build-wrapper-output.bypass=true sonar.cfamily.build-wrapper-output=build-wrapper.json sonar.language=swift sonar.test.inclusions=*.swift sonar.swift.project= $(Pipeline.Workspace)/s/xxx.xcodeproj sonar.swift.workspace= $(Pipeline.Workspace)/s/xxx.xcworkspace sonar.exclusions=xxx sonar.coverage.exclusions=xxxx sonar.coverageReportPaths=sonarqube-generic-coverage.xml
It looks like you’re doing your utmost to only analyze your Swift code (BTW some of these parameters won’t have any effect).
So if you’re setting up your project to only include Swift files, how / why do you expect it to show coverage for Objective-C?
Below is the latest properties and getting error on execution at step sonar cloud analyze. Screenshot attached.
So you’ve commented out the property setting Objective-C file suffixes to
- and now analysis is actually trying to analyze them. And since you’re not building with the build wrapper before analysis, you’re getting an error. The docs should help.
a. Used C/C++/Objective-C | SonarCloud Docs
b. Downloaded build wrapper for Mac
c. Added to repository.
d. From that folder, trying to run command
e. It fails stating ''command not found" (Note: facing this error in ado agent and as well as in local Mac machine)
Command used in ado task:
chmod 777 build-wrapper-macosx-x86
build-wrapper-macosx-x86 --out-dir build_wrapper_output_directory xcodebuild clean build
/Users/runner/work/_temp/a3377dae-4ccc-412d-91be-631b6ec8cc4f.sh: line 5: build-wrapper-macosx-x86: command not found
-rwxrwxrwx 1 runner staff 197888 Apr 18 10:46 build-wrapper-macosx-x86
-rw-r–r-- 1 runner staff 29504 Apr 18 10:46 libinterceptor.dylib
I’m not going to be able to tell you how to install something on an ADO build agent. In any other context, I’d advise you to make sure the command was added to the
$PATH variable. That may help here as well.
I added the $PATH environment variable and was able to execute the command. Post which I am able to view the files with objective c extension (.m) in the sonar cloud portal. However, the test case files of objective c files are not visible in the portal. Also the .m files are with coverage 0%. Let me know if anything missing.
extraProperties: | sonar.c.file.suffixes=- sonar.sourceEncoding=UTF-8 sonar.cpp.file.suffixes=- #sonar.objc.file.suffixes=- sonar.cfamily.cache.enabled=false #sonar.cfamily.build-wrapper-output=false #sonar.cfamily.build-wrapper-output.bypass=true sonar.cfamily.build-wrapper-output=build-wrapper.json #sonar.language=swift sonar.test.inclusions=*.swift sonar.swift.project= $(Pipeline.Workspace)/s/xyz.xcodeproj sonar.swift.workspace= $(Pipeline.Workspace)/s/xyz.xcworkspace sonar.exclusions=xyz sonar.coverage.exclusions=xyz sonar.coverageReportPaths=sonarqube-generic-coverage.xml sonar.cfamily.build-wrapper-output=build_wrapper_output_directory
sonar.test.inclusions=*.swift. That instructs analysis to only consider files in project root with a
.swift file extension. Assuming that’s not what you want, you should drop that parameter and simply set
sonar.tests to the directory where your test files are located.
Included property sonar.tests with folders containing unit test.
Post execution, able to view the test files in the Sonarcloud portal.
However, its coverage is 0%. Tried to add a new method into an existing test file, but its coverage is still shown as 0.
Also the xml file which was created and assigned as part of
has only .swift files and not objective c files.
You’re saying that only
.swift files are tested? That shouldn’t really matter.
Can you post your analysis log?