I am trying to use Github Actions to run an xcodebuild command on my xcworkspace.
However, any configuration fails with the error Unable to find a destination matching the provided destination specifier: { platform: iOS Simulator, OS: latest, name:iPhone 11 Pro }
Here is my swift.yml file
name: Unit Tests
on: [push]
jobs:
test:
runs-on: macOS-latest
steps:
- uses: actions/checkout#v2
- name: List Simulators
run: xcrun instruments -s
- name: Run tests
run: xcodebuild test -workspace "MyWorkspace.xcworkspace" -scheme "MyScheme" -destination "platform=iOS Simulator,name=iPhone 11 Pro,OS=latest"
As you can see, I am also logging all available devices on the CI machine. This clearly shows me several iPhone 11 Pro (Max).
Things I already tried:
use specific OS version
lower build target
force Xcode version to 11.3
grep ID of a simulator from the above-mentioned list and use that instead of the name parameter
boot simulators before running tests
Am I missing anything obvious?
Cheers and happy coding.
Force Xcode version to Xcode 11.3 and clean test
name: Unit Tests
on: [push]
jobs:
test:
runs-on: macOS-latest
steps:
- uses: actions/checkout#v2
- name: Force Xcode 11
run: sudo xcode-select -switch /Applications/Xcode_11.3.app
- name: List Simulators
run: xcrun instruments -s
- name: Run tests
run: xcodebuild clean test -workspace 'MyWorkspace.xcworkspace' -scheme 'MyScheme' -destination 'platform=iOS Simulator,name=iPhone 11 Pro Max,OS=latest'
Related
I have swift package for iOS apps (it needs UIKit to run). I wan't to build this package using Github action this is how my workflow looks like
name: Swift
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout#v2
- uses: YOCKOW/Action-setup-swift#master
with:
swift-version: '5.3'
- name: Build
run: swift build -v
- name: Run tests
run: swift test -v
When I run this build I got error: no such module 'UIKit'.
So I have 2 options:
make my package UIKit independent (actually don't know how)
configure build to run on iOS specifically
What should I do?
We're using xcodebuild instead of swift build to do platform specific CI from GitHub Actions. See specific example at https://github.com/firebase/firebase-ios-sdk/blob/master/.github/workflows/spm.yml and https://github.com/firebase/firebase-ios-sdk/blob/master/scripts/build.sh#L540
The simplest approach as of 2022 is to use xcodebuild like stated above.
Condensed to the basics, the script can be as simple as this:
# This workflow will build a Swift project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift
name: Build and Test
on:
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout#v3
# Sanity check to make sure we use a valid device in the next step
- name: List available devices
run: xcrun simctl list devicetypes
#generic/platform=iOS is sufficient for just building, - but need to specify concrete destination for tests
- name: Build and run tests
run: xcodebuild test -scheme YourSchemeNameHere -destination 'platform=iOS Simulator,name=iPhone 13 Pro' #or any other name from the list of sim devices
This is enough to build the project and run tests on it.
In some cases you may need to install a later version of Swift than what's available by default on Github Actions, - you can use a third party step for that and use xcode-select.
I am using Charts in my app and I am trying to run a CI/CD pipeline in Github Actions. Charts is added to the project via SwiftPackageManager.
Currently, the app builds and runs on my local machine, but when I am building in Github Actions, I am getting the following error:
CompileSwift normal arm64 (in target 'Charts' from project 'Charts')
Any idea how to fix this? The workflow files looks like this:
# This workflow will build a Swift project
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-swift
name: Swift
on:
push:
branches: [ "features" ]
jobs:
build:
runs-on: macos-12
steps:
- name: Checkout
uses: actions/checkout#v3
- name: Build
run: xcodebuild clean build -workspace GSH.xcworkspace -scheme GSH CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO ONLY_ACTIVE_ARCH=NO
Charts environment:
Charts version/Branch/Commit Number: 4.0.2
Xcode version: 13.3
Swift version: 5.0
Platform(s) running Charts: iOS
macOS version running Xcode: macOS Monterey 12.6
I am new to Github actions and I was trying to make an action to attempt a build and see if the build passes or fails an Xcode iOS build but I keep getting the error
line 1: cd: Swift/: No such file or directory
6
Error: Process completed with exit code 1.
Any help would be appreciated!
Code:
name: Xcode build iOS 14
on: [push, pull_request]
jobs:
build:
runs-on: macos-11
steps:
- uses: actions/checkout#v2
- name: Select Xcode
run: sudo xcode-select -switch /Applications/Xcode_13.3.app
- name: Xcode version
run: /usr/bin/xcodebuild -version
- name: Xcode build
run: |
cd Swift/
xcodebuild clean build -scheme MyApp -destination 'platform=iOS Simulator,name=iPhone 12,OS=14.4'
I would try cd Swift instead of cd Swift/ , if you have Swift folder in your project.
I am interested in running build for my Swift project on CI with GitHub Actions
I use the following ci.yml:
Build:
runs-on: macOS-latest
steps:
- name: Install Swift
uses: slashmo/install-swift#v0.2.1
with:
version: 5.7
- name: Checkout
uses: actions/checkout#v1
- name: Build
uses: sersoft-gmbh/xcodebuild-action#v2
with:
project: <Project>.xcodeproj
scheme: <Scheme>
destination: "platform=iOS Simulator,name=iPhone 14 Pro Max"
action: build
I am facing a problem here:
xcodebuild: error: Could not resolve package dependencies:
package at '/Users/runner/work/path/to/my/package' is using Swift tools version 5.7.0 but the installed version is 5.5.0
I want to use swift-tools-version equal to 5.7.0, not the lower one
Please, help me install the version I need
Looks like I made it work. I added this step in my workflow:
- name: Select Xcode
run: sudo xcode-select -s "/Applications/Xcode_14.0.1.app"
and then specified the simulator environment:
env:
destination: 'platform=iOS Simulator,name=iPhone 14 Pro,OS=16.0'
I am new at using Github Actions,Have written below ios.yml file and getting error like
Error: Process completed with exit code 70. on execution.
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
build:
name: Build and Test default scheme using any available iPhone simulator
runs-on: macos
steps:
- name: Checkout
uses: actions/checkout#v2
- name: Set Default Scheme
run: sudo xcodebuild clean build test -workspace testing.xcworkspace -scheme "testing" -sdk iphonesimulator -destination "platform=iOS Simulator,OS=15.4,name=iphone 8" CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO```
Try removing CODE_SIGN_IDENTITY="" and test