Build-wrapper on MacOS causes xcodebuild to be unable to access files in iOS project

  • SonarQube Developer Edition - Version 8.6
  • build-wrapper, version 6.15 (macosx-x86)
  • Mac OS X 10.15.7
  • Xcode 12.0

I am trying to scan Objective-C code in an iOS Xcode project. Using the build-wrapper, I get the following errors:

dyld: warning: could not load inserted library '/Users/ios.minis/workspace/workspace/taylesworth_sonarqube-objc_ios-CompileOnly/root/ios/build-wrapper-macosx-x86/libinterceptor.dylib' into hardened process because no suitable image found.  Did find:
/Users/ios.minis/workspace/workspace/taylesworth_sonarqube-objc_ios-CompileOnly/root/ios/build-wrapper-macosx-x86/libinterceptor.dylib: code signature in (/Users/ios.minis/workspace/workspace/taylesworth_sonarqube-objc_ios-CompileOnly/root/ios/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/ios.minis/workspace/workspace/taylesworth_sonarqube-objc_ios-CompileOnly/root/ios/build-wrapper-macosx-x86/libinterceptor.dylib: stat() failed with errno=1

Following that, there are a number of errors apparently trying to read Pods-related xcconfig files:

error: /Users/ios.minis/workspace/workspace/taylesworth_sonarqube-objc_ios-CompileOnly/root/ios/Pods/Target Support Files/Pods-TargetCommon-TempoUniversal/Pods-TargetCommon-TempoUniversal.debug.xcconfig: unable to open file (in target "TempoUniversal" in project "TempoUniversal") (in target 'TempoUniversal' from project 'TempoUniversal')

And then it finally fails with:

xcodebuild[68326:26276548] Error writing xctestrun file: Error Domain=NSCocoaErrorDomain Code=4 "The folder “TempoUniversal Tests_iphonesimulator14.0-x86_64.xctestrun” doesn’t exist." UserInfo={NSFilePath=/Users/ios.minis/workspace/workspace/taylesworth_sonarqube-objc_ios-CompileOnly/root/ios/artifacts/test/build/unittests/Build/Products/TempoUniversal Tests_iphonesimulator14.0-x86_64.xctestrun, NSUserStringVariant=Folder, NSUnderlyingError=0x7fb317b81f60 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}

The xcodebuild command is invoked using:

env NSUnbufferedIO=YES ./build-wrapper-macosx-x86/build-wrapper-macosx-x86 --out-dir /Users/ios.minis/workspace/workspace/taylesworth_sonarqube-objc_ios-CompileOnly/root/ios/artifacts/build_wrapper_output xcodebuild -workspace ./workspace.xcworkspace -scheme TempoUniversal\ Tests -destination 'platform=iOS Simulator,id=0AFDD318-3F17-4194-A244-7CD8E22D57EE' -derivedDataPath '/Users/ios.minis/workspace/workspace/taylesworth_sonarqube-objc_ios-CompileOnly/root/ios/artifacts/test/build/unittests' build-for-testing

The above command works fine without the build wrapper. I’ve seen there are several related topics over the past year but I haven’t seen a specific solution that I think applies to my case. Any help is much appreciated.

Hi @Tom_Aylesworth ,

let me apologize for the delay. What version of the build-wrapper are you using?

Thanks @mpaladin. I think that’s what you are asking for, right?

Hi @Tom_Aylesworth ,

yes, could you try to split build and test and wrap only the build part with the build-wrapper and run the tests without build-wrapper?

Hi @mpaladin , it should already be doing that. We are using fastlane’s scan utility and this CI job is using the build_for_testing option and then storing the build artifacts in an S3 bucket. Another CI job pulls down those artifacts and uses scan’s test_without_building option to run the tests.

I could try building with the build wrapper by hand if you think there might be something about the way scan is invoking xcodebuild to do this. But looking at the xcodebuild command I added to my original post, it looks good and includes the build-for-testing parameter.

Hi @Tom_Aylesworth ,

it would be nice if you could provide a minimal reproducer project which would help us to reproduce it on our side. Do you think you could help with that?

Sorry for the delays between posts. I’m adding sonarqube scanning to our ios code as a side project. I’ll see if I can get a small project to reproduce the issue and let you know.

Hi @Tom_Aylesworth ,

ok, thanks, any hello world project would be great.