I am currently using travis-ci to run builds/unit tests on every github checkins I make for my iOS project. One of my unit test deals with iOS keychain store, and locally when I run the unit tests, they all pass.
However, on my travis-ci server, it fails with the following error:
Aug 6 23:01:31 itako16044.miso xctest[2160] <Error>: SecOSStatusWith error:[-25291] The operation couldn’t be completed. (com.apple.security.xpc error 3 - <connection: 0x5a8f430> { name = com.apple.securityd, listener = false, pid = 0, euid = 4294967295, egid = 4294967295, asid = 4294967295 }: Connection invalid)
I am a n00b when it comes to travis-ci, and some google searches did not yield anything useful. Is there something I am missing? How can I set up travis such that I can write things into the keychain store for iOS (it looks like I cannot access keychain store)?
Are you using xctool? I was having the same problem, but I managed to fix it by using xcodebuild instead. My travis.yml looks like this:
language: objective-c
before_script:
- brew update
- brew install xctool && brew cleanup xctool
script:
- cd NitroKeychain
- xcodebuild -project NitroKeychain.xcodeproj -scheme NitroKeychain -destination 'platform=iOS Simulator,name=iPhone Retina (4-inch)' test
It looks like xctool is having some issue accessing the keychain.
Anyway, you can see my project travis.yml and its settings here: https://github.com/danielalves/NitroKeychain
Related
I have a requirement to use exactly iOS 14.5 on our pipeline.
I tried the following:
variables:
sdk: 'iphoneos14.5' // I also tried to iphoneos
- task: Xcode#5
inputs:
actions: 'test'
configuration: '$(configuration)'
sdk: '$(sdk)'
xcWorkspacePath: 'MyProject.xcworkspace'
scheme: '$(secondaryScheme)'
xcodeVersion: 'specifyPath'
xcodeDeveloperDir: '/Applications/Xcode_13.2.1.app'
packageApp: false
destinationPlatformOption: 'iOS'
destinationSimulators: 'iPhone 11,OS=14.5'
args: '-derivedDataPath $(agent.buildDirectory)/DerivedData'
But both runs failed with
xcodebuild: error: SDK "iphoneos14.5" cannot be located.
##[error]Error: /usr/bin/xcodebuild failed with return code: 64
And
xcodebuild: error: Unable to find a destination matching the provided destination specifier:
{ platform:iOS Simulator, OS:14.5, name:iPhone 11 }
That's what I understood from reading the preinstalled software documentation. https://github.com/actions/virtual-environments/blob/main/images/macos/macos-11-Readme.md
Grateful if you could tell me what I am doing wrong
By using your pipeline definition, I am able to reproduce your issue.
I think below YAML file will help you understand why the official document said 'iOS 14.5' is supported but you can't use it.
pool:
name: Azure Pipelines
#Your build pipeline references an undefined variable named ‘secondaryScheme’. Create or edit the build pipeline for this YAML file, define the variable on the Variables tab. See https://go.microsoft.com/fwlink/?linkid=865972
steps:
- script: |
xcodebuild -showsdks
echo "========================================================="
sudo xcode-select -switch /Applications/Xcode_12.5.1.app/Contents/Developer
xcodebuild -showsdks
displayName: 'Command Line Script'
When you see the result of the pipeline run, I believe you will understand everything:
After switching the version, you should be able to use the specific IOS version you want.
Reference: https://developer.apple.com/documentation/security/notarizing_macos_software_before_distribution/customizing_the_notarization_workflow
You upload your app for notarization using notarytool command line
tool. Xcode 13 or later supports this tool, so if you have more than
one version of Xcode installed on your Mac, be sure to use the
xcode-select utility to choose an appropriate version:
% sudo xcode-select -s /path/to/Xcode13.app
Added this step
gem install xcode-install
xcversion simulators --install='iOS 13.5'
If someone finds a way to use the installed sdk for other Xcode, please comment here
So I just recently added a POD to my project which then required me to use/load workspaces instead of the individual project. That's all fine and dandy but now the build script that we use to ultimately build the project (see below) will build successfully but upon installation, I've discovered upon examining the device console logs (some lines pasted below) while trying to install it that it fails to do so because of the parent bundle identifier is the same as the sub-bundle (I assume this is referring to this one library I added - JSONWebToken).
I suppose the question I have is how do I get around this? We have a script that appends the appropriate bundleId (we have multiple apps we build from the same code base). It seems to me xcodebuild will use this bundleId correctly for the main app but it is using it for the POD package as well. How do I get around this using xcodebuild?
xcodebuild -workspace "CompanyOne.xcworkspace" -scheme "Arrow" -configuration "Release" archive -archivePath "~/Library/Developer/Xcode/Archives/2021-12-01/Envoy Bag Drop 12-01-21 11.23 PM.xcarchive" -allowProvisioningUpdates PRODUCT_BUNDLE_IDENTIFIER=com.companyone.retail.demo PRODUCT_NAME="Envoy Bag Drop" GCC_PREPROCESSOR_DEFINITIONS='USE_SKIN_INCLUDE=1 RETAIL=1 SKIN_OVERRIDE_KEY=#\"*retail\"' | tee "/tmp/_xc-archive_envoy-demo_Release/build.log" | grep --color -E 'warning:|error:'
installd 0x16b54f000 -[MIInstallableBundle performPreflightWithError:]: 433: The parent bundle has the same identifier (com.luxerone.retail.demo) as sub-bundle at /var/installd/Library/Caches/com.apple.mobile.installd.staging/temp.DUYvYU/extracted/Payload/Arrow.app/Frameworks/JWT.framework
default 17:31:21.582751-0800 installd 0x16b54f000 -[MIInstaller performInstallationWithError:]: Preflight stage failed
default 17:31:21.582992-0800 runningboardd Invalidating assertion 31-271-3129 (target:system) from originator [daemon<com.apple.mobile.installd>:271]
I'm trying to perform the conversion for SonarQube to interpret coverage and I get this error:
Error: Error Domain=XCCovErrorDomain Code=0 "Failed to load result bundle" UserInfo={NSLocalizedDescription=Failed to load result bundle, NSUnderlyingError=0x7fdaa840a8d0 {Error Domain=IDEFoundation.ResultBundleError Code=0 "This version of Xcode does not support opening result bundles created with versions of Xcode and xcodebuild using the v1 API."}}
The operation couldn’t be completed. (cococoLibrary.Bash.Error error 0.)
The solution was to update slather to version 2.5 and also generate coverage in the sonarqube generic mode. Follow the steps for successful reproduction:
Build
xcodebuild -workspace 'YourProject.xcworkspace' -scheme DEV -derivedDataPath Build/ -enableCodeCoverage YES clean build test CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO -destination 'platform=iOS Simulator,name=iPhone 8,OS=14.0'
Slather generate sonarqube generic xml
slather coverage --jenkins --sonarqube-xml --build-directory ./Build --output-directory ./sonar-reports --scheme DEV --workspace YourProject.xcworkspace
Run analise Sonarqube
sonar-scanner -Dsonar.sources=. -Dsonar.coverageReportPaths=./sonar-reports/sonarqube-generic-coverage.xml -Dproject.settings=sonar-project.properties -Dsonar.qualitygate.wait=true
This page gives steps to generate code coverage for various Xcode versions. there are primarily 3 steps as shown in the description.
Build project
Create code coverage report
Import code coverage report
https://github.com/SonarSource/sonar-scanning-examples/tree/master/swift-coverage
This is a popular page to integrate CI with Sonar as well, its from SonarSource.
I am trying to run sonar swift.
I have already sonarQube with the plugin and I can access it locally using this url http://localhost:9000 . I have installed all prerequisites that you can find here :
https://github.com/Backelite/sonar-swift
But I can't figure out what is this error when i launch run-sonar-swift.sh.
If anyone can bring me the light I would be very grateful.
Here the logs when I run in terminal command ./run-sonar-swift.sh -v :
MacBook-Air:streamus-phoenix-ios oboujaouane$ ./run-sonar-swift.sh -v
Running run-sonar-swift.sh...
Project count is [1]
Xcode project file is: Streamus.xcodeproj
Xcode workspace file is: Streamus.xcworkspace
Xcode application scheme is: Streamus Alpha
Destination simulator is: platform=iOS Simulator,name=iPhone 6,OS=11.3
Excluded paths from coverage are: .Tests.
Creating directory sonar-reports/
Running tests
+ xcodebuild clean build test -workspace Streamus.xcworkspace -scheme 'Streamus Alpha' -configuration Debug -enableCodeCoverage YES -destination 'platform=iOS Simulator,name=iPhone 6,OS=11.3' -destination-timeout 60
2018-05-12 10:34:14.031 xcodebuild[32149:775290] IDETestOperationsObserverDebug: Writing diagnostic log for test session to:
/var/folders/9v/vdbbf4j96hxgcxmtpntznytr0000gn/T/com.apple.dt.XCTest/IDETestRunSession-9A7EF764-6391-4C7D-9F34-066A9DFEC5E9/StreamusUITests-87E838E0-4F8F-4C19-B2AC-C2C0A274E8EC/Session-StreamusUITests-2018-05-12_103414-jhm3wz.log
2018-05-12 10:34:14.032 xcodebuild[32149:769805] [MT] IDETestOperationsObserverDebug: (98FB295E-FE60-46AA-8589-015B0DD2E617) Beginning test session StreamusUITests-98FB295E-FE60-46AA-8589-015B0DD2E617 at 2018-05-12 10:34:14.031 with Xcode 9E145 on target {
SimDevice: iPhone 6 (672DE879-E48B-45DA-BFD9-D0412F51A706, iOS 11.3, Booted)
} (11.3 (15E217))
2018-05-12 10:34:14.061 xcodebuild[32149:769805] [MT] IDETestOperationsObserverDebug: (458F86F6-1492-40F1-9F72-A88FC23BD985) Beginning test session StreamusTests-458F86F6-1492-40F1-9F72-A88FC23BD985 at
2018-05-12 10:34:14.061 with Xcode 9E145 on target {
SimDevice: iPhone 6 (672DE879-E48B-45DA-BFD9-D0412F51A706, iOS 11.3, Booted)
} (11.3 (15E217))
2018-05-12 10:34:14.061 xcodebuild[32149:770075] IDETestOperationsObserverDebug: Writing diagnostic log for test session to:
/var/folders/9v/vdbbf4j96hxgcxmtpntznytr0000gn/T/com.apple.dt.XCTest/IDETestRunSession-9A7EF764-6391-4C7D-9F34-066A9DFEC5E9/StreamusTests-4F203461-1372-49B7-A806-F130F168079E/Session-StreamusTests-2018-05-12_103414-MfIreE.log
2018-05-12 10:34:30.016 xcodebuild[32149:769805]
Error Domain=IDETestOperationsObserverErrorDomain Code=14 "Test operation was canceled. If you believe this error represents a bug, please attach the log file at /var/folders/9v/vdbbf4j96hxgcxmtpntznytr0000gn/T/com.apple.dt.XCTest/IDETestRunSession-9A7EF764-6391-4C7D-9F34-066A9DFEC5E9/StreamusUITests-87E838E0-4F8F-4C19-B2AC-C2C0A274E8EC/Session-StreamusUITests-2018-05-12_103414-jhm3wz.log"
UserInfo={NSLocalizedDescription=Test operation was canceled. If you believe this error represents a bug, please attach the log file at /var/folders/9v/vdbbf4j96hxgcxmtpntznytr0000gn/T/com.apple.dt.XCTest/IDETestRunSession-9A7EF764-6391-4C7D-9F34-066A9DFEC5E9/StreamusUITests-87E838E0-4F8F-4C19-B2AC-C2C0A274E8EC/Session-StreamusUITests-2018-05-12_103414-jhm3wz.log}
2018-05-12 10:34:30.016 xcodebuild[32149:769805] Error Domain=IDETestOperationsObserverErrorDomain Code=14 "Test operation was canceled. If you believe this error represents a bug, please attach the log file at /var/folders/9v/vdbbf4j96hxgcxmtpntznytr0000gn/T/com.apple.dt.XCTest/IDETestRunSession-9A7EF764-6391-4C7D-9F34-066A9DFEC5E9/StreamusTests-4F203461-1372-49B7-A806-F130F168079E/Session-StreamusTests-2018-05-12_103414-MfIreE.log" UserInfo={NSLocalizedDescription=Test operation was canceled. If you believe this error represents a bug, please attach the log file at /var/folders/9v/vdbbf4j96hxgcxmtpntznytr0000gn/T/com.apple.dt.XCTest/IDETestRunSession-9A7EF764-6391-4C7D-9F34-066A9DFEC5E9/StreamusTests-4F203461-1372-49B7-A806-F130F168079E/Session-StreamusTests-2018-05-12_103414-MfIreE.log}
Testing failed:
Linker command failed with exit code 1 (use -v to see invocation)
** TEST FAILED **
The following build commands failed:
Ld /Users/oboujaouane/Library/Developer/Xcode/DerivedData/Streamus-gwtdwpbaxrfgafdtejzjtpxyhhhq/Build/Intermediates.noindex/Streamus.build/Alpha-iphonesimulator/StreamusTests.build/Objects-normal/x86_64/StreamusTests normal x86_64
Ld /Users/oboujaouane/Library/Developer/Xcode/DerivedData/Streamus-gwtdwpbaxrfgafdtejzjtpxyhhhq/Build/Intermediates.noindex/Streamus.build/Alpha-iphonesimulator/StreamusTests.build/Objects-normal/i386/StreamusTests normal i386
(2 failures)
returnValue=65
set +x
ERROR - Command 'xcodebuild clean build test -workspace Streamus.xcworkspace -scheme Streamus Alpha -configuration Debug -enableCodeCoverage YES -destination platform=iOS Simulator,name=iPhone 6,OS=11.3 -destination-timeout 60' failed with error code: 65
In advance thank you,
It seems that error was due to provisioning profile. When I added my Provisioning Profile and try it again the problem was resolved.
Then I had another problem with MessageKit:“Segmentation fault: 11”
It was a CocoaPods Podfile config issue.
So I had to switch compilation mode for Debug from "Single File" to "Whole Module” by click on Pods in Xcode project navigator then select MessageKit in targets of pods then Builds settings tab then in searcher tap ‘compilation mode’ and switch “Single File” to “Whole Module” and re-run script run-sonar-swift.sh

⚠️ each time you make a pod install / update or something that can change pods you have to switch compilation mode for Debug from "Single File" to "Whole Module” for the pod which give you an error when you launch run-sonar.swift.sh with -v for verbose.
After that it was not yet the end of my problems! In fact I had a last problem which was an error with SwipeCellKit pod:
“No such module SwipeCellKit”.
To resolve this problem follow instructions given here https://stackoverflow.com/a/37732248/6188918
Then I tried again and the rest of the script started (SwiftLint, Tailor & Lizard) and I thought this time it was finally good but an error occurred once again a new error message at the end of the script concerning Lizard which was:
ERROR: Error during SonarQube Scanner execution
ERROR: File
MyprojectName/Domains/Repositories/Local/cacheManager.swift can't be
indexed twice. Please check that inclusion/exclusion patterns produce
disjoint sets for main and test files
ERROR: Re-run SonarQube Scanner using the -X switch to enable full
debug logging.
To resolve this inclusion/exclusion I followed the answer given here:
https://stackoverflow.com/a/40150551/6188918
by adding these to line in sonar-project.properties file below sonar.swift.excludedPathsFromCoverage line:
sonar.test.inclusions=**/*Test*/**
sonar.exclusions=**/*Test*/**
I tried again but with parameter -notailor(run script and skip Tailor):
./run-sonar-swift.sh -notailor -v
just to save a little time because tailor take time
And after launch the script... Boom a new error... But it was a known issue:
Error: Caused by: org.sonar.api.measures.PersistenceMode
And the issue is explained here https://github.com/Backelite/sonar-swift/issues/118
So I downloaded this .jar file “backelite-sonar-swift-plugin-0.4-sonar-7-quick-fix.jar” found here https://github.com/Hugal31/sonar-swift/releases/tag/0.4-sonar-7-quick-fix and replace it in plugins of my local SonarQube and try again.
…and this time after an umpteenth launch I finally saw the light 🤪💡
Hope this answer will help and if you have a question don’t hesitate.
Good luck & have fun :)
PS: You’ll find here some options to run script with parameters:
./run-sonar-swift.sh -noswiftlint -v (run script with verbose option and skip SwiftLint)
./run-sonar-swift.sh -notailor -v (run script with verbose option and skip Tailor)
./run-sonar-swift.sh -nounittests -v (if your project does not have scheme configured to be tested launch with this parameter)
If you want more info check in run-sonar-swift.sh script and check around lines 125 ## COMMAND LINE OPTIONS
PS2: I have also opened an issue in sonar-swift GitHub if it can help: https://github.com/Backelite/sonar-swift/issues/138
I had an extra issue with oclint: oclint: Not enough positional command line arguments specified!. So I had to modify the run-sonar-swift.sh script a little bit in order to get it working: https://gist.github.com/Edudjr/79a2379842357c33709aecf040d9ae77#file-run-sonar-swift-sh
And this is a model of my sonar-project.properties: https://gist.github.com/Edudjr/db51907068ea76b116d11d9a9b13f05f#file-sonar-project-properties
I've been trying to setup Travis CI as a build server, but am running into problems both code signing the app, and uploading it to TestFlight.
The main issue is uploading to Apple TestFlight. I can find a lot guides online on how to upload to the old version of TestFlight at testflightapp.com, but I've not figured out how to upload to iTunes Connect.
I attempted to use the altool command:
altool --upload-app -f "$OUTPUTDIR/$APP_NAME.ipa" -u '$ITUNES_CONNECT_USERNAME' -p '$ITUNES_CONNECT_PASSWORD'
But on Travis CI it doesn't work:
altool: command not found
-
I've primarily used the following tutorials to get this far: http://www.raywenderlich.com/109418/travis-ci-tutorial and https://www.objc.io/issues/6-build-tools/travis-ci/#app-signing
This is a useful official page:
http://docs.travis-ci.com/user/languages/objective-c/
-
This is my project setup:
.travis.yml file:
language: objective-c
osx_image: xcode7.1
xcode_workspace: XXXXXXX.xcworkspace
xcode_scheme: XXXXXXX
env:
global:
- APP_NAME="XXXXXX"
- DEVELOPER_NAME="iPhone Distribution: XXXXXXX (XXXXXXX)"
- PROFILE_NAME="XXXXXXXXXXXXX"
- ITUNES_CONNECT_USERNAME="XXXXXX#XXXXXX.com"
- secure: XXXXXXXXXXXXXXXXXXXXXX
before_script:
- ./scripts/add-key.sh
- ./scripts/update-bundle.sh
script:
- xctool -workspace XXXXXXX.xcworkspace -scheme XXXXXXX -sdk iphoneos -configuration
Release OBJROOT=$PWD/build SYMROOT=$PWD/build ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY=""
CODE_SIGNING_REQUIRED=NO
after_success:
- ./scripts/sign-and-upload.sh
after_script:
- ./scripts/remove-key.sh
Note that the CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO on the end of the build command is there because otherwise the app fails to build (see https://github.com/travis-ci/travis-ci/issues/3047 for details, and https://stackoverflow.com/a/11647504/404409 for more info on it). This is probably a cause of the code signing issue described below.
The add-key.sh, sign-and-upload.sh and remove-key.sh scripts are basically just copied direct from https://www.objc.io/issues/6-build-tools/travis-ci/#add-scripts
With the exception of this line being added the end of sign-and-upload.sh:
altool --upload-app -f "$OUTPUTDIR/$APP_NAME.ipa" -u '$ITUNES_CONNECT_USERNAME' -p '$ITUNES_CONNECT_PASSWORD'
-
The app builds, but this is the output from the sign-and-upload.sh script at the end:
env SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS9.1.sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/PackageApplication /Users/travis/build/XXXXXX/ios/build/Release-iphoneos/XXXXXXX.app -o /Users/travis/build/XXXXXX/ios/build/Release-iphoneos/XXXXXXX.ipa -sign iPhone\ Distribution\=XXXXXXXXXXXX -embed /Users/travis/Library/MobileDevice/Provisioning\ Profiles/XXXXXXXXXXX.mobileprovision
error: Failed to read entitlements from '/var/folders/my/XXXXXXXXXXXXXXXXXXX/X/XXXXXXXXX/Payload/Kimono.app'
./scripts/sign-and-upload.sh: line 20: altool: command not found
-
If you have any clues as to how iOS apps should be done on Travis CI, or how to submit builds to TestFlight over the command line I would be eternally grateful!
Thank you.
On my machine, there is no altool in my PATH, but xcrun altool works. Maybe try that?