Analyzing Objective-C (iOS project) via Bitbucket Pipelines

  • 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 (atlassian/default-image:2), namely /opt/atlassian/pipelines/agent/build. Unfortunately, this hack also didn’t work, as SonarCloud tried to use my local clang:

ERROR: Cannot run program “/Applications/” (in directory “/opt/atlassian/pipelines/agent/build/demo/Pods”): error=2, No such file or directory
ERROR: Caused by: Cannot run program “/Applications/” (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.

Hi @afi_iag,

don’t you have any CI for this project? For objective-C it is required to have the build in order to do the analysis.

Unfortunately workarounds do not work, not worth to try.

Analysis requires to run on the same machine where it is built, it should answer your question.

Forget about these, they don’t affect functionalities.

like I wrote in the beginning of the post, CI is self-hosted Jenkins.

This isn’t clear from the documentation. I think it should be explicitly stated, that analyzing objc files of a macos/ios/tvos app can’t be done via Bitbucket Pipelines. (although this is possible for swift files)

Thank you for the response!

Hi @afi_iag,

Nothing prevents you to push to SonarCloud.

The documentation explicitly says to wrap the build of your own project, it is kind of clear that if you have a xcode project you need a macos slave.