SonarQube build-wrapper silently fails - sonarqube

I'm running the build-wrapper like so:
build-wrapper-macosx-x86 --out-dir build_wrapper_output xcodebuild -project MyProject.xcodeproj -scheme All -configuration Release clean build
However, when I look at the result output the json file is empty:
# (C) SonarSource SA, 2014-2022, info#sonarsource.com
# All SONARSOURCE programs and content are copyright protected.
# SONARSOURCE and SONARQUBE are trademarks of SonarSource SA. All rights are expressly reserved.
#
# This file is designed exclusively for use with the SONARSOURCE C / C++ / Objective-C Plugin.
# It may not be used in connection with any other software.
# Any other use is prohibited by law and may be grounds for immediate termination of your License.
{
"version":"6.35",
"captures":[
]}
When I run xcodebuild normally the build works. Is there something I'm missing here? I tried reading the following and followed the instructions:
https://docs.sonarqube.org/latest/analysis/languages/cfamily/

Finally I found the solution. build wrapper doesnot support Mac os Ventura 13.x
SonarCommunity, Build wrapper is not working as expected, Objective C, XCode
Initially, I had used this command: xcodebuild clean build -workspace
PagaloTodo.xcworkspace -Scheme PagaloTodo and the build is successful.
I had tried passing others configuration options as arch, sdk,
BUILD_LIBRARIES_FOR_DISTRIBUTION where also the build is successful
but the build wrapper generated file is uncomplete.
There is a jira ticket created for same.

Related

Does xcode use "xcodebuild" under the hood?

Does xcode use of the xcodebuild command behind the scenes to build?
If so, how can I find the exact xcodebuild command that is run?
I checked the report navigator but couldn't find it in there.
I would have thought that running xcodebuild -sdk iphonesimulator -configuration Debug -project <myproject>.xcodeproj -scheme <myscheme> would be identical to selecting product -> build in xcode (with a scheme/destination matching the command line), but they seem to have slightly different behavior.
For example, when running the command line above with the -showBuildSettings option, I noticed that BUILD_ACTIVE_RESOURCES_ONLY=NO even though it should be set to YES according to the target's build settings. When running product -> build from xcode, the build settings logs (generated by following #Slipp D. Thompson's answer here) show BUILD_ACTIVE_RESOURCES_ONLY=YES.
There are few other strange differences I noticed as well.
No. One could do an experiment: move all xcodebuild binaries in some local folder and check that Xcode still able to build some application.
Since Apple presents xcodebuild as a self contained command line tool for building Xcode projects, it is reasonable to suspect that use code sharing between both tools.

Xcode 9.2: Size Discrepancy between Release builds inside Xcode and using xcodebuild

It appears that when building with Xcode 9.2, binaries generated with xcodebuild are slightly larger than by using Xcode's regular 'Build for Profiling' command. Both are set to generate Release builds, the configuration for command-line builds is also set to 'Release' and this did not occur with previous versions of Xcode.
These are the frameworks with their respective sizes when building from within Xcode:
And these are generated by xcodebuild:
I suspect that some debug or code coverage data is left in some of the frameworks when using xcodebuild.
FYI: A previous build had way larger C binaries (e.g. sqlite3.framework was several megabytes in size). After discovering https://github.com/Carthage/Carthage/issues/2056, I disabled code coverage in the 'Test' action of my build scheme and disabled the "Undefined Behavior" sanitizer. Before that, the frameworks were even larger (again, note sqlite3.framework) and there was a dylib from the "Undefined Behavior" sanitizer which should not be present in Release builds:
Did anyone encounter something similar and/or was able to fix this issue? Happy to provide the output of e.g. nm or otool if that helps (and you tell me which options to pass to those tools to generate meaningful information).
P.S.:
I am using this command for xcodebuild:
xcodebuild -workspace Timing.xcworkspace -scheme 'Timing 2' -configuration 'Release' -derivedDataPath build clean build
I did enable parallel builds with
defaults write com.apple.dt.Xcode BuildSystemScheduleInherentlyParallelCommandsExclusively -bool NO
and am using the new Xcode build system, however the issue also appears with the "regular" build settings. Plus, there should not be a difference between the outputs of Xcode's build step and xcodebuild in either case. Also, sqlite3.framework is built via CocoaPods, but that should not matter, either.
Looks like the extra data was code coverage data injected due to xcodebuild adding the compiler options -profile-generate -profile-coverage-mapping. The "solution" was to uncheck the "Gather coverage data" option on the "Test" scheme action, even though xcodebuild was not building for testing.

'Cordova/CDVViewController.h' file not found when run in Xcode terminal

So when I am trying to build my code from xcode terminal it is failing and giving me an error of 'Cordova/CDVViewController.h' file not found but when I am building this from xcode then it is building just fine.
In my Xcode, I've done the whole Cordova sub directory thing Upgrade Cordova. Also when I ran list. This is what I see below:
xcodebuild -list
Information about project "myProject":
Targets:
myProject
Build Configurations:
Debug
Release
If no build configuration is specified and -scheme is not passed then "Release" is used.
Schemes:
myProject
CordovaLib
Environment: Xcode5, OS 10.8.5
Is there anything I am missing? The reason why I am doing this because I am trying to run this through jenkins. I thought it was a jenkins issue but then I got it down to the xcode terminal not seeing the CordovaLib.
I've spent too much time figuring out the solution for this so it is a shame not to share. There can be many possible reasons why this problem arise but if you feel like you've set up everything right in the CordovaLib (like me!) and still has the same problem. This can be one of the causes. What's happening is when I ran the
xcodebuild -scheme myProject -configuration "Release"
it is building successfully, but if you don't supply "-scheme" it it will fail by default it is using the "Release". The parameters of the scheme will control which targets are built and how they are built, myProject scheme contains the subfolder and reference to Cordovalib.
Now, moving to Jenkins, is you need to supply the scheme in the "Xcode Schema File" text box in the Advanced Xcode build options section of the XCode Plugin.
My set-up is Xcode as my slave but this may still apply to whatever Xcode and Jenkins combination you have - so when I ran the
xcodebuild -list
I receive the message the following message:
If no build configuration is specified and -scheme is not passed then "Release" is used.
This project contains no schemes.
The solution for this is, in your xcode project, go to Product|Scheme|Manage Scheme and checked "Shared" to both projects myProject and CordovaLib. Compile. Check-in (because I am grabbing this from TFS). Ran again the "-list" command and you will see the schemes that you just shared.
Hope this helps!
Thanks a lot !
Just adding "-scheme" and "-configuration" parameters fixed the problem for me.
If it can help someone else, here is the full command line i used :
xcodebuild -scheme MyProject -configuration "Release" -arch i386 -sdk iphonesimulator7.1
I used it to generate a ios simulator build in order to submit an Phonegap / Cordova application to the Facebook Review
In build settings
add this item to "Header Search Path"
$(OBJROOT)/UninstalledProducts/$(PLATFORM_NAME)/include

Jenkins xcode plugin - how to resolve library search path issues?

I am running into this error in my jenkins xcode build which I'm attempting to setup:
clang: error: no such file or directory: '/Users/boo/.jenkins/jobs/myProject/workspace/DerivedData/Release-iphoneos/libIBAForms.a'
clang: error: no such file or directory: '/Users/boo/.jenkins/jobs/myProject/workspace/DerivedData/Release-iphoneos/libLambdaAlert.a'
clang: error: no such file or directory: '/Users/boo/.jenkins/jobs/myProject/workspace/DerivedData/Release-iphoneos/libRestKit.a'
I cannot figure out a few things regarding the configuration:
what prompted the jenkins-xcode-plugin ( https://wiki.jenkins-ci.org/display/JENKINS/Xcode+Plugin ) to use /DerivedData/Release-iphoneos/ in the path for the lookup of the .a files
instead why didn't it select /DerivedData/Debug-iphoneos/ as the fragment in the path for the lookup to the .a files
finally the submodules that produce - libIBAForms, libLambdaAlert, libRestKit - are all projects that have a release and a debug profile ... so why the files are actually missing from the /DerivedData/Release-iphoneos/ path where they are supposed to be ... is beyond me.
Regarding points #1 and #2, this is configured based on the Configuration parameter for XCode plugin (and Xcode itself). By default, the plugin uses "Release" value for the parameter. If you want to use "Debug", you should set it as such.
Don't know what to say regarding #3
Personally, i found the Xcode plugin to be restrictive and not providing me with options that i needed. I am using the command line tools that came with xcode (through regular Execute Shell build step)
// Below are my build parameters for the job through regular means
CONFIGURATION=Debug
CODE_SIGN_IDENTITY=iPhone Developer: <DeveloperNameHere>
PROVISIONING_PROFILE=3000000B-7000-4000-9CD5-D0000B0F0000
//
// Code for Execute Shell
xcodebuild -verbose -alltargets -configuration ${CONFIGURATION} clean build CODE_SIGN_IDENTITY="${CODE_SIGN_IDENTITY}" PROVISIONING_PROFILE=${PROVISIONING_PROFILE}
&&
/usr/bin/xcrun -sdk iphoneos PackageApplication -v "${WORKSPACE}/path_here/${CONFIGURATION}-iphoneos/application.app" -o "${WORKSPACE}/path_here/${CONFIGURATION}-iphoneos/application.ipa" --sign "${CODE_SIGN_IDENTITY}" --embed "/Users/<youruser>/Library/MobileDevice/Provisioning Profiles/${PROVISIONING_PROFILE}.mobileprovision"
Setup parameters as usual for the job
The xcodebuild command does the actual build
The xcrun command packages the app into an IPA (the Archive step in Xcode), signs it, and embeds a provisioning profile directly into the IPA.
Note that some of these switches are options and may not be required for you. But that's the benefit of doing through the command line: you have full control of what you want to do
Small note: make sure you provide full paths to -v and -o switches on the second command
I was able to get past all this when I adeed the submodules which generate libIBAForms and libLambdaAlert as the main project's "Target Dependencies"

Can anyone give an example of how to configure Bamboo to build an Xcode project?

I've been searching for how to configure Bamboo (a continuous integration system) to build an Xcode project. This should be pretty simple, as it is just getting it to run a shell command such as:
xcodebuild -project ProjectName -target TargetName -configuration ConfigType
However this is proving more difficult than expected. I've investigated creating a "custom builder" for the xcodbuild command (tells Bamboo about the command) but then it only seems to let you pass ONE argument to the command not the multiple that the xcodebuild command requires. Any help or pointers would be much appreciated, including links to any appropriate examples (I couldn't find any.) Thanks.
OK, I got a "HelloWorld" example working by choosing the "script" option with a shell script rather than a "custom builder" and trying to tell Bamboo how to use xcodebuild command directly. Just specified a script like below.
#!/bin/bash
/usr/bin/xcodebuild -project TestProject/TestProject.xcodeproj -target TestProject -configuration Release build
That might have done the trick but there is a more generic way to do it.
You can define in your agent capabilities as a Command to execute /usr/bin/xcodebuild. Then in your tasks after you checkout your code, you can define a task Command, and you can select Xcode from the drop down list and provide the arguments needed for the project in the relevant input -workspace YourProject.xcworkspace -scheme YourProject. This approach provides more flexibility since Xcode installation can differ from agent to agent but bamboo will still be able to forward your builds properly where they can be build.

Resources