Xcode 8 Build with Jenkins CI - ios

I'm having issues with automated jenkins build on a mac pro using Xcode 8.1 with xcodebuild.
I would like my setup to:
Pull down code for git (working)
Archive (Archive fails)
Create .ipa
Deploy to TestFairy
My archive script is failing but still creating ProjectName-Daily.xcarchive file:
xcodebuild -workspace ProjectName.xcworkspace -scheme ProjectName-Daily -configuration Release clean archive -archivePath ~/ProjectName-Daily.xcarchive DEVELOPMENT_TEAM=1234567890
Fails with the following on the terminal with no description on error. I also tried -verbose and no luck
I then tried to build it manually and get a build succeeds with the following errors:
I then went to archive the build on Xcode and it worked just fine. Not sure why the script isn't working on the CI machine. Also tried the script on my personal macbook pro and it worked just fine.
Any thoughts?

Related

Code Signing issue when Archiving using Fastlane in Github actions

Recently we have migrated all of our iOS projects from GitLab to GitHub. However when we are trying to build the code using GitHub
Actions(Fastlane) In our self-hosted runners it keeps falling with error mentioned below.
When building(gym) the project it signs with correct certificates and profiles but when archiving it somehow uses the development certificate to sign the pods.
Command Executed:
set -o pipefail && xcodebuild -workspace ./{ProjectName}.xcworkspace -scheme UAT -destination 'generic/platform=iOS' -archivePath /Users/{user}/Library/Developer/Xcode/Archives/2022-05-03/{ProjectName}\ 2022-05-03\ 16.13.00.xcarchive -allowProvisioningUpdates clean archive | tee /Users/{user}/Library/Logs/gym/{ProjectName}-UAT.log | xcpretty
Note: It used to archive fine with Gitlab pipelines. Also, it builds fine when the commands are run manually on the hosted runner.
iOS: macOS Big Sur 11.6
XCode: 13.0 and 13.2.1
What we've tried:
Locking and Unlocking keychain.
Re-creation and re-installing certificates
Upgrading Ruby
Running on different machines(We have 2 runners)
Restarting and Cleaning the runners
Deintegrated and Integrated pods.
Did you try to pod install? The error indicates a problem with ur build phases script added by Cocoapods. maybe deintegrate and integrate Cocoapods again.

Build Xcode project from command line that use OneSignalNotificationServiceExtension

I am trying to build an Ios app with Objective-C xcode project
The project is using OneSignalNotificationServiceExtension that is why I am specifying the architecture.
the command:
xcodebuild ARCHS=armv6,armv7 ONLY_ACTIVE_ARCH=NO build
but the compilation fails and It throws an error:
Exiting because upload-symbols was run in validation mode
The reason I am doing this is because I need to use the sonarqube wrapper and it takes the build command as argument:
sonar-wrapper --out-dir=bw-output <<build command>>
but I am only able to build the xcode project using xcode
If there is a better way to integrate sonarqube to this kind of projects let me know please.
Maybe try using Fastlane instead of using the xcodebuild CLI directly, I find Fastlane is much more user friendly. I use it for my CI/CD deployments.
It looks like there is some Sonarqube integration as well:
https://docs.fastlane.tools/actions/sonar/
Website: https://fastlane.tools
I successfully built the project specifying the debug mode, workspace and scheme like this:
xcodebuild -configuration Debug -workspace <<workspace>> -scheme <<scheme>> clean build

Xcode UI Tests : xcodebuild fails to generate Coverage.profdata on xcode12, fails with error 'error: No profiles could be merged.'

Here is how we are setup while facing the issue.
We have a project which has both UI and Unit tests.
Uses fastlane.
Has CI/CD implementation using Jenkins which runs on an aws ec2 instance.
Quite recently we moved to Xcode12 (I know!!! However, better late than never)
Problem statement:
After moving to xcode12, the jenkins pipeline is unable to generate the Coverage.profdata file which in turn will be used by Slather to derive code coverage metrics. Yes, did not happen when running xcode11.
We are using the xcodebuild command after pointing it to the appropriate command line tool version (in this case it is 12.4).
First we build the app using (after getting the simulator ID)
xcodebuild build-for-testing -workspace Example.xcworkspace -scheme ExampleUITests -derivedDataPath ./derivedData -destination 'platform=iOS Simulator,id=<simulator_id>'
Then we run the test using
xcodebuild test-without-building -workspace Example.xcworkspace -scheme ExampleUITests -enableCodeCoverage YES -destination 'platform=iOS Simulator,id=<simulator_id>' -derivedDataPath ./derivedData
All the UI tests run successfully but end up with the following statements when the test suite completes.
warning: <Path_to_derived_data>/Build/ProfileData/<Some_UUID>/<Filename>.profraw: Invalid instrumentation profile data (file header is corrupt)
error: No profiles could be merged.
P.S: This is not happening on my local machine. Only on the mac in the Jenkins ec2 instance.
We faced a similar issue. We were also using fastlane.
And the fix which worked for us was to ensure we delete any artifacts from the previous build. The situation you've described is quite similar to situation we faced. The first run for unit tests generates a few coverage artifacts, after which executing UI tests also generates coverage artifacts and then xcov/slather is unable to parse these artifacts.
Therefore, can you check if deleting the Logs/Test folder in derived data helps? If it doesn't try clearing derived data entirely and then check if that helps resolve the issue on CI.
See related threads on xcov

TeamCity + Xcode 6 - Run Test action fails

I am trying to make a simple Xcode project work with TeamCity. Without running any tests I have succeeded.
I have a basic, Single View Application in Swift with one label on the screen. Both TeamCity (9.0.2) and Xcode (6.1.1) runs on the same machine (Mac mini) with an OS X (10.10.2) Server (4.0.3) installed on it. I have created a Git repository with Server and added as a remote to my sample Xcode project. After that, I've created successfully a working TeamCity project and build.
However when I try to check the Run tests checkmark the build WILL fail no matter what I do.
Configuration (dropbox image)
https://dl.dropboxusercontent.com/u/55101816/Screen%20Shot%202015-03-01%20at%2002.45.48.png
Error message (and the messages right before that)
[02:31:48][FirstTeamCityProjectTests (BUILD)] Touch
[02:31:48][Touch] Touch build/Debug-iphoneos/FirstTeamCityProjectTests.xctest
[02:31:48][Touch] cd /Library/TeamCity/buildAgent/work/55b27ad210b8fe77
[02:31:48][Touch] export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/> ontents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Server.app/Contents/ServerRoot/usr/bin:/Applications/Server.app/Contents/ServerRoot/usr/sbin"
[02:31:48][Touch] /usr/bin/touch -c /Library/TeamCity/buildAgent/work/55b27ad210b8fe77/build/Debug-iphoneos/FirstTeamCityProjectTests.xctest
[02:31:48][FirstTeamCityProjectTests (BUILD)] CodeSign
[02:31:48][CodeSign] CodeSign build/Debug-iphoneos/FirstTeamCityProjectTests.xctest
[02:31:48][CodeSign] cd /Library/TeamCity/buildAgent/work/55b27ad210b8fe77
[02:31:48][CodeSign] export CODESIGN_ALLOCATE=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate
[02:31:48][CodeSign] export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Applications/Xcode.app/ Contents/Developer/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Server.app/Contents/ServerRoot/usr/bin:/Applications/Server.app/Contents/ServerRoot/usr/sbin"
[02:31:48][CodeSign] Signing Identity: "iPhone Developer: *"
[02:31:48][CodeSign] /usr/bin/codesign --force --sign * /Library/TeamCity/buildAgent/work/55b27ad210b8fe77/build/Debug-iphoneos/FirstTeamCityProjectTests.xctest
[02:31:48][Step 1/1] ** BUILD SUCCEEDED **
[02:31:48][Step 1/1] xcodebuild: error: Failed to build workspace FirstTeamCityProject with scheme FirstTeamCityProject.
[02:31:48][Step 1/1] Reason: Xcode cannot run using the selected device.
[02:31:48][Step 1/1] Process exited with code 70
[02:31:48][Step 1/1] Step Xcode Project failed
Main problem I found with this error code and CI that they were trying with ssh and there were no GUI session. Currently I have a valid GUI session with the same user it uses, so it shouldn't be a problem.
The xcodebuild command is the following.
/Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace FirstTeamCityProject.xcodeproj/project.xcworkspace -scheme FirstTeamCityProject SYMROOT=/Library/TeamCity/buildAgent/work/55b27ad210b8fe77/build OBJROOT=/Library/TeamCity/buildAgent/work/55b27ad210b8fe77/build clean build test
What is missing here (I suppose) is one or more destinations.
I've executed the following command and it worked just fine. (Opened the Simulator, then exited with success.)
xcodebuild test -project FirstTeamCityProject.xcodeproj -scheme FirstTeamCityProject -destination 'platform=iOS Simulator,name=iPhone 6,OS=8.1'
I seem to be alone with this problem, I didn't find any other relevant hits. Looking at this tutorial: http://pivotallabs.com/ios-continuous-deployment-teamcity-hockeyapp/, my issue should not be present at all.
EDIT:
The destination is indeed missing, but I don't understand why. Moreover if I try to add it manually the build fails. (I suspect that the order of the parameters matters, but how could I add this destination elsewhere in TeamCity.)
[01:48:12][Step 1/1] Building project: /Library/TeamCity/buildAgent/work/55b27ad210b8fe77/FirstTeamCityProject.xcodeproj
[01:48:12][Step 1/1] Using Xcode 6.1.1
[01:48:12][Step 1/1] Starting: /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace FirstTeamCityProject.xcodeproj/project.xcworkspace -scheme FirstTeamCityProject SYMROOT=/Library/TeamCity/buildAgent/work/55b27ad210b8fe77/build OBJROOT=/Library/TeamCity/buildAgent/work/55b27ad210b8fe77/build clean build test -destination 'platform=iOS Simulator,name=iPhone 6,OS=8.1'
[01:48:12][Step 1/1] in directory: /Library/TeamCity/buildAgent/work/55b27ad210b8fe77
[01:48:12][Step 1/1] xcodebuild: error: option 'Destination' requires at least one parameter of the form 'key=value'
I appreciate any idea you have! Thanks in advance!
in team city, when you configure the 'Xcode Project' build step,
add the destination parameter in the 'Additional command line parameters'
input box like so:
"-destination" "platform=iOS Simulator,name=iPhone 6,OS=8.4"
pay attention to the quotation marks
that solved the issue for me (I checked it on TeamCity Professional 9.1.5 (build 37377)).
Please see How to start TeamCity Build Agent on Mac OS on a user logon to make it able to run the GUI applications (also see the note for Yosemite OS).

OCLint and xcode project

since yesterday I'm trying to make OCLint works with my iOS project.
What I've done so far is to follow these instructions to install OCLint, then I've followed these other instructions to use it within Xcode. The problem is that when I try to build the OCLint aggregate target the build process never end (I've waited 30 minutes before stopping it). Is someone experiencing the same issue? the OCLint version I'm using is oclint-0.9.dev.3f9355e
try this on Terminal
xctool -workspace xx.xcworkspace -scheme xx -reporter json-compilation-database:compile_commands.json clean
xctool -workspace xx.xcworkspace -scheme xx -reporter json-compilation-database:compile_commands.json build
oclint-json-compilation-database

Resources