Objective-C build-wrapper with fastlane

Versions: SonarQube 7.6, Sonar-Scanner, SonarCFamily 6.1

What are you trying to achieve: run build-wrapper-macosx-x86 and fastlane scan together, or optimize running them separately.

I am currently running build-wrapper-macosx-x86 with xcodebuild as a shell command, then the scan command.

sh("cd .. && build-wrapper-macosx-x86 --out-dir sonar-reports xcodebuild -workspace workspace.xcworkspace -scheme scheme clean build")

        scheme: "scheme",
        output_directory: "./sonar-reports",
        code_coverage: true,
        workspace: "workspace.xcworkspace",
        skip_build: true

However, this builds twice and takes a long time on larger projects. Ideally, fastlane will add the option to include the build-wrapper command. Until that happens, I would be happy with any recommendations to optimize the order/settings of these commands.

Is anyone else using build-wrapper-macosx-x86 with fastlane?

Hello @aclaus,

in order to build once you should run it externally and not plug it inside fastlane configuration file:

build-wrapper-macosx-x86 --out-dir sonar-reports
sonar-scanner -D sonar.cfamily.build-wrapper-output=sonar-reports …


I discovered a way to use the build wrapper in the same build of the Fastlane scan.
You can use the xcodebuild_command parameter like this:

scan(scheme: "scheme",
    output_directory: "./sonar-reports",
    code_coverage: true,
    workspace: "workspace.xcworkspace",
    skip_build: true,
    xcodebuild_command: "env NSUnbufferedIO=YES build-wrapper-macosx-x86 --out-dir ./build/build_wrapper_output xcodebuild")

I found this on Github, applied in my mixed objective-c/swift project and it’s working fine.


@brbsBruno Excellent find! Thanks for updating!

I ended up doing it the other way around, and found it worked. Calling fast lane with the build-wrapper.

bash: ‘build-wrapper-macosx-x86 --out-dir sonar-reports bundle exec fastlane test’