- ALM used: Bitbucket Cloud
- CI system used: self-hosted Jenkins
- Languages of the repository: Objective-C, Swift
I have a library written in Objective-C which is accompanied by a demo app written in Swift. The source resides in a private Bitbucket repository, SonarCloud is integrated via Bitbucket Pipelines. CI system is self-hosted Jenkins with nodes running macOS.
I was able to analyze a pure Swift project set up in a similar way without any issues. But how to achieve this for Objective-C? I’ve read that build wrapper must be run first together with build command, which in my case is
build-wrapper-macosx-x86 --out-dir compilation-database xcodebuild -workspace demo/demo.xcworkspace -scheme Demo clean build
but macOS docker images don’t exist, so it seems that it’s impossible to run xcodebuild via Bitbucket Pipelines.
I tried to work this around by running
build-wrapper-macosx-x86 on local machine and putting results to the repository to let SonarCloud analyze them, but that failed with “0 files to analyze”. I figured out that the generated files contain absolute paths to the source code files that are valid only on the local machine, so I replaced them with those used in the docker image (
/opt/atlassian/pipelines/agent/build. Unfortunately, this hack also didn’t work, as SonarCloud tried to use my local
ERROR: java.io.IOException: Cannot run program “/Applications/Xcode10.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang” (in directory “/opt/atlassian/pipelines/agent/build/demo/Pods”): error=2, No such file or directory
ERROR: Caused by: Cannot run program “/Applications/Xcode10.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang” (in directory “/opt/atlassian/pipelines/agent/build/demo/Pods”): error=2, No such file or directory
ERROR: Caused by: error=2, No such file or directory
So my question is: how to actually analyze Objective-C files via Bitbucket Pipelines? Is it possible at all or must be done completely on a local machine?
P.S. Also when I ran build-wrapper-macosx-x86, I received the following messages:
dyld: warning: could not load inserted library ‘/Users/kambala/Downloads/build-wrapper-macosx-x86/libinterceptor.dylib’ into hardened process because no suitable image found. Did find:
/Users/kambala/Downloads/build-wrapper-macosx-x86/libinterceptor.dylib: code signature in (/Users/kambala/Downloads/build-wrapper-macosx-x86/libinterceptor.dylib) not valid for use in process using Library Validation: mapped file has no cdhash, completely unsigned? Code has to be at least ad-hoc signed.
/Users/kambala/Downloads/build-wrapper-macosx-x86/libinterceptor.dylib: stat() failed with errno=1
but seems that build wrapper files were generated without issues. I’m running macOS 10.14.6 with SIP disabled.