SonarSource/sonar-scanning-examples

xccov-to-sonarqube-generic.sh does not support XCode 11

emanuelschmoczer opened this issue · 14 comments

With XCode 11 the format of result bundles changed. Instead of *.xccovarchive now xcodebuild produces .xcresult (see release notes. and Testing in Xcode).
Using the current version of xccov-to-sonarqube-generic.sh on an xcresult-bundle results in following error:

Error: unrecognized file format

@agigleux any news on this?
We're getting ready to switch to Xcode 11 but currently the coverage reporting is blocking us from doing so.

Same for me :(

Just wanted to surface this here, that we are disabling sonar and looking at alternative solutions. 😞

Sorry for the radio silence, you should definitely post your feedback on https://community.sonarsource.com/ where SonarSourcers are there every day.

The xccov-to-sonarqube-generic.sh is just an example of script to transform a *.xccovarchive into the Generic Coverage format supported by SonarQube. I mean this .sh script is not supported by SonarSource itself.

Can you post a Change Request on https://community.sonarsource.com/c/suggestions/features to officially request a solution to support Xcode 11 coverage format?

In the meantime, keep in mind that if the .xcresult file format is a JSON/XML format, it should not be complicated for one of you to transform it into the format expected by SonarQube: https://docs.sonarqube.org/latest/analysis/generic-test/

In the meantime, keep in mind that if the .xcresult file format is a JSON/XML format, it should not be complicated for one of you to transform it into the format expected by SonarQube: https://docs.sonarqube.org/latest/analysis/generic-test/

@agigleux there is already a possible solution in #64

I made this fix, but now I got another error, do you have any idea about this? Thanks!

Requested but did not find extension point with identifier Xcode.IDEFoundation.IDEResultKitSerializationConverter
Error: Error Domain=XCCovErrorDomain Code=0 "Failed to load coverage report for scheme action 'Testing workspace appName with scheme appNameTests' in result bundle" UserInfo={NSLocalizedDescription=Failed to load coverage report for scheme action 'Testing workspace appName with scheme appNameTests' in result bundle, NSUnderlyingError=0x7f9f45faf5d0 {Error Domain=NSCocoaErrorDomain Code=260 "The file “action.xccovreport” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/tmp/action.xccovreport, NSUnderlyingError=0x7f9f45fc8170 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}}}

@diegommlima I did not encounter this error yet. Do you have a github repo with the project somewhere or any other way I could reproduce this error?

I get a similar error like @diegommlima:
Requested but did not find extension point with identifier Xcode.IDEFoundation.IDEResultKitSerializationConverter
For me, it does not complain about being unable to load the coverage report. However, conversion now takes several hours and seems to be incomplete (percentage is significantly lower in SQ).

Edit: I did some adjustments on our build machines. Coverage is back to normal, but conversion still takes >1hour (~10 minutes before). Alas, I cannot supply a sample project at the moment.

I made this fix, but now I got another error, do you have any idea about this? Thanks!

Requested but did not find extension point with identifier Xcode.IDEFoundation.IDEResultKitSerializationConverter
Error: Error Domain=XCCovErrorDomain Code=0 "Failed to load coverage report for scheme action 'Testing workspace appName with scheme appNameTests' in result bundle" UserInfo={NSLocalizedDescription=Failed to load coverage report for scheme action 'Testing workspace appName with scheme appNameTests' in result bundle, NSUnderlyingError=0x7f9f45faf5d0 {Error Domain=NSCocoaErrorDomain Code=260 "The file “action.xccovreport” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/tmp/action.xccovreport, NSUnderlyingError=0x7f9f45fc8170 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}}}

@diegommlima Even I am getting same error! were you able to resolve the error ?

I made this fix, but now I got another error, do you have any idea about this? Thanks!

Requested but did not find extension point with identifier Xcode.IDEFoundation.IDEResultKitSerializationConverter
Error: Error Domain=XCCovErrorDomain Code=0 "Failed to load coverage report for scheme action 'Testing workspace appName with scheme appNameTests' in result bundle" UserInfo={NSLocalizedDescription=Failed to load coverage report for scheme action 'Testing workspace appName with scheme appNameTests' in result bundle, NSUnderlyingError=0x7f9f45faf5d0 {Error Domain=NSCocoaErrorDomain Code=260 "The file “action.xccovreport” couldn’t be opened because there is no such file." UserInfo={NSFilePath=/tmp/action.xccovreport, NSUnderlyingError=0x7f9f45fc8170 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}}}

@diegommlima Even I am getting same error! were you able to resolve the error ?

Unfortunately not yet.. :( and I can't supply a sample project at the moment too.
Obs.: I don't know if it's important, but my project use multi-modules..

I ran all my tests and got the latest .xcresult directory from DerivedData to generate the .xml file

Works on Xcode 11.1
Updating to Xcode 11.2 will require to change the command line tools to Xcode 11.1 (11A1027) for this command to work

bash xccov-to-sonarqube-generic.sh /DerivedData/yourApp/Logs/Test/Test-yourApp.xcresult > sonarqube-generic-coverage.xml

@kuriishu27: what performance did you experience? (size of .xcresult bundle and time needed for the conversion would be great, amount of tests and source files even better)

Yes, @kuriishu27 is correct after switching using the new Test Plans in Xcode 11 only the the test executed with the Xcode 11.1 command line tools version, not with newer ones.

If I don't use the new Test Plans then I can still use the lates command line tools (11.3.1 at the moment) I'll create a ticket for this.

Hi,
If you are using cocoapods in your projects, code coverage support will be provided with the '1.9.0' update.
Check release notes 1.9.0 > https://github.com/CocoaPods/CocoaPods/releases