mxcl / xcodebuild Goto Github PK
View Code? Open in Web Editor NEWA continuously resilient `xcodebuild` “GitHub Action”. Also it’s the best.
License: The Unlicense
A continuously resilient `xcodebuild` “GitHub Action”. Also it’s the best.
License: The Unlicense
https://github.com/mxcl/xcodebuild/runs/2754225991
Run ./
with:
platform: macOS
xcode: ^11
working-directory: fixture
code-coverage: false
action: test
quiet: true
Selected Xcode 11.7.0
Error: SyntaxError: Unexpected token b in JSON at position 93
https://github.com/chris-araman/CombineCloudKit/runs/2754115546
Run chris-araman/xcodebuild@tweaks
with:
action: build
platform: tvOS
xcode: ~11.3
quiet: false
code-coverage: false
env:
TOOLCHAINS:
Selected Xcode 11.3.1
Error: SyntaxError: Unexpected token b in JSON at position 106
I wonder whether this might be related to this issue, resolved in Xcode 12.5:
xcodebuild no longer double-escapes the output of xcodebuild -showBuildSettings -json. (63554669)
From the Xcode 13 Release Notes:
xcodebuild
now supports the use of App Store Connect API keys for authentication with the Apple Developer website. This enables the use of automatic signing viaxcodebuild
in headless environments, such as build machines and continuous integration setups. To use API keys withxcodebuild
, create an API key on App Store Connect and pass the key along with its identifier and your team’s issuer identifier toxcodebuild
using the new parametersauthenticationKeyPath
,authenticationKeyID
, andauthenticationKeyIssuerID
, respectively. When creating a key, you can assign it a role to control its permissions for performing automatic signing tasks. To learn more about creating and managing keys, see Creating API Keys for App Store Connect API. (51444716)
This looks like it might allow for a better way to enable automatic code signing when invoking Xcode 13 and later.
The variables profiles
and mobileProfiles
in
Line 179 in 133bcda
This causes the inputs mobile-provisioning-profiles-base64
and provisioning-profiles-base64
to be swapped.
However, this should only be applied to build targets, not tests
I think there needs to be an GH Action input to specify the workspace file
because this package doesn't find my workspace. I believe I need to build with workspace because I use CocoaPods and I'm getting this error:
no such module 'Alamofire'
import Alamofire
^
** BUILD FAILED **
The following build commands failed:
CompileSwift normal x86_64
CompileSwiftSources normal x86_64 com.apple.xcode.tools.swift.compiler
(2 failures)
exec: xcodebuild -destination id=86BA49D1-96[18](https://github.com/xxxx/xxxx-ios/runs/6098816862?check_suite_focus=true#step:10:18)-4B0F-8A41-1B9741[22](https://github.com/xxxx/xxx-ios/runs/6098816862?check_suite_focus=true#step:10:22)DCBA -scheme myapp -configuration Release -resultBundlePath build.xcresult build
Here's my xcodebuild list without and with workspace:
# /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -list -json
{
"project" : {
"configurations" : [
"Debug",
"Release"
],
"name" : "myapp",
"schemes" : [
"StoreKitTests",
"myapp"
],
"targets" : [
"myapp",
"myappTests",
"myappUITests"
]
}
}
# /Applications/Xcode.app/Contents/Developer/usr/bin/xcodebuild -workspace myapp.xcworkspace -list -json
{
"workspace" : {
"name" : "myapp",
"schemes" : [
"Alamofire",
"Alamofire-SwiftyJSON",
"AlamofireImage",
"....
"myapp",
"....
]
}
}
I am confused, because the action errors, but the tests run without any issues locally.
I get a lot of errors like this:
cannot infer contextual base in reference to member 'vertical'
.padding(.vertical, 15)
~^~~~~~~~~~
What version do I have to use, to make it work?
I only specified the ios version in the project.yml configuration but this builder needs a swift version or xcode version.
I am trying to run my tests with the following workflow:
name: propromo.ios CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
runs-on: macos-latest
# Use macos-latest and trust this action to always work
# This because GitHub deprecate old environments, so if you want your CI to continue to work in 5 years you need to use latest
# This makes specifying specific xcode versions problematic however, we haven’t got a good story for this yet.
strategy:
matrix:
platform:
- iOS
#xcode:
# - ^14
# https://flatgithub.com/mxcl/.github/?filename=versions.json&sha=7f6f9803a64ce8a542970f9f04eb1b39b8b76946
# https://github.com/actions/runner-images/blob/main/images/macos/macos-11-Readme.md#xcode
#swift:
# - ^4
# - ^5
scheme:
- UnitTests
- UiTests
steps:
- name: Checkout Code
uses: actions/checkout@v4
- name: Install Dependencies
run: |
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
brew install xcodegen
- name: Generate Project
run: xcodegen generate
- uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: ${{ matrix.xcode }}
# Versions:
# https://xcodereleases.com/
# https://developer.apple.com/support/xcode/
- name: Xcode Tests
uses: mxcl/xcodebuild@v2
with:
#xcode: ${{ matrix.xcode }}
platform: ${{ matrix.platform }}
# swift: ${{ matrix.swift }}
action: test # `build`
code-coverage: false # default = `false`
warnings-as-errors: false # default = `false`
scheme: ${{ matrix.scheme }}
This is my project.yml file:
name: Propromo
settings:
GENERATE_INFOPLIST_FILE: YES
MARKETING_VERSION: 0.0.0
CURRENT_PROJECT_VERSION: 0.0.0
options:
bundleIdPrefix: com.propromo
packages:
Alamofire:
url: https://github.com/Alamofire/Alamofire
majorVersion: 5.5.0
targets:
Propromo:
type: application
platform: iOS
deploymentTarget: "17.0"
sources:
- path: ./core/features
group: propromo
- path: ./core/resources
group: propromo
- path: ./core/services
group: propromo
dependencies:
- package: Alamofire
# Link with its target to run with cmd+u
scheme:
gatherCoverageData: true
testTargets:
- name: UnitTests
parallelizable: true
randomExecutionOrder: true
scheme:
gatherCoverageData: true
testTargets:
- name: UiTests
parallelizable: true
randomExecutionOrder: true
UnitTests:
type: bundle.unit-test
platform: iOS
sources:
- path: ./core/tests/unit
group: propromo
# Link with ./core target
dependencies:
- target: Propromo
# Create a new scheme that will be linked and configured for test purposes
scheme:
gatherCoverageData: true
testTargets:
- name: UnitTests
parallelizable: true
randomExecutionOrder: true
UiTests:
type: bundle.ui-testing
platform: iOS
sources:
- path: ./core/tests/ui
group: propromo
# Link with ./core target
dependencies:
- target: Propromo
# Create a new scheme that will be linked and configured for test purposes
scheme:
gatherCoverageData: true
testTargets:
- name: UiTests
parallelizable: true
randomExecutionOrder: true
SwiftPM projects use swift package describe --type json
, for Xcode projects xcodebuild -list -json
.
When I used this action build a iOS project using below code:
- uses: mxcl/xcodebuild@v1
with:
platform: iOS
action: build
configuration: release
working-directory: project/ios
scheme: XXX
I get the below log:
▸ xcodebuild build
.....
▸ Touching XXX.framework (in target 'XXX' from project 'XXX')
▸ Build Succeeded
Now i want to get XXX.framework
and upload, but i can't find a way to set the output dir
I am new to ios development. I tried running the action without specifying the scheme, but it failed.
I am not sure if I put in the right scheme name, when I tried it with that option.
I just set scheme: to the key I found in .xcodeproj/.xcuserdatad/xcschememanagement.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>SchemeUserState</key>
<dict>
<key><project>.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>0</integer>
</dict>
</dict>
</dict>
</plist>
Is this the correct scheme?
If not, where can I find it?
I got this error using the scheme <project>
:
xcodebuild: error: Unable to find a destination matching the provided destination specifier:
{ id:E9F9EF49-C801-4410-98EE-FEEAFABE7[28](https://github.com/<project>-software/<project>.ios/actions/runs/8215195540/job/22468406013#step:5:29)D }
Ineligible destinations for the "<project>" scheme:
{ platform:iOS, id:dvtdevice-DVTiPhonePlaceholder-iphoneos:placeholder, name:Any iOS Device }
{ platform:iOS Simulator, id:dvtdevice-DVTiOSDeviceSimulatorPlaceholder-iphonesimulator:placeholder, name:Any iOS Simulator Device }
exec: xcodebuild -destination id=E9F9EF49-C801-4410-98EE-FEEAFABE728D -scheme <project>-resultBundlePath test.xcresult -enableCodeCoverage YES test
This seems to be a dead-end, because the action does not allow to set a destination, right?
We figure out the the simulator destination for you automatically. Stop specifying fragile strings like platform=iphonesimulator,os=14.5,name=iPhone 12 that will break when Xcode updates next week.
Hi, I see there is a cron runner action to try to update this stuff automagically, but not sure if its picked up the macOS 12 image with Xcode 13.3?
The macOS 12 image is listed here:
https://github.com/actions/virtual-environments/blob/main/images/macos/macos-12-Readme.md
Would be nice.
ALSO: we should allow uploading the raw build log as an artifact (perhaps on by default)
To determine Swift versions for Xcode versions we can use:
https://github.com/mxcl/.github/blob/main/.github/workflows/sniff.yml
(Import it here).
Then every day update a JSON file this action can use to determine Xcode version for Swift semantic version.
Then if we cannot get a specific Swift version we can download it like other actions do, this would allow us to support new Swift on macOS quickly and when the image adds the Xcode that provides it, switch to that making the action quicker.
Run mxcl/[email protected]
with:
xcode: 15.4.0
platform: iOS
code-coverage: true
action: test
scheme: Catalog
warnings-as-errors: false
verbosity: xcpretty
upload-logs: on-failure
» Selected Xcode 15.4.0
Creating provisioning profiles
xcodebuild test
--- xcodebuild: WARNING: Using the first of multiple matching destinations:
{ platform:iOS Simulator, id:80649341-558[2](https://github.com/.../actions/runs/9566252578/job/26371076440#step:3:2)-4C55-8B4F-067A86FFEACE, OS:18.0, name:iPhone SE ([3](https://github.com/.../actions/runs/9566252578/job/26371076440#step:3:3)rd generation) }
When adding the workspace
flag (which is very helpful for projects using cocoapods) to this action, there were two PRs:
#80 got merged and #81 was closed without merging. However, #81 had an update to the README.md
file to introduce the newly introduced workspace
flag which did not make it into master
.
Since this is a very useful flag, I think the documentation for it should be added to the README.md
Hrm... This doesn't look right.
https://github.com/chris-araman/CombineCloudKit/runs/3234261677?check_suite_focus=true
(node:892) UnhandledPromiseRejectionWarning: Error: `xcodebuild` aborted (65)
37
at xcodebuild_xcodebuild (/Users/runner/work/_actions/mxcl/xcodebuild/v1/src/xcodebuild.ts:25:1)
38
at process.action (internal/process/task_queues.js:93:5)
39
at /Users/runner/work/_actions/mxcl/xcodebuild/v1/src/index.ts:135:1
40
(node:892) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
41
(node:892) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
The job "succeeded". 🤔
Investigating...
It should be possible to specify the visionOS platform now that it's generally available in Xcode.
So uses: mxcl/xcodebuild@v3
causes the error.
When using mxcl/xcodebuild@v1
, the workflow logs the following warning:
The
save-state
command is deprecated and will be disabled soon. Please upgrade to using Environment Files. For more information see: https://github.blog/changelog/2022-10-11-github-actions-deprecating-save-state-and-set-output-commands/
If this is not fixed, this action will stop working by June this year.
We've got a build that looks something like:
- uses: ruby/setup-ruby@v1
with:
bundler-cache: true
- uses: mxcl/xcodebuild@v1
with:
working-directory: app/ios
scheme: AppTests
platform: iOS
When there's no bundler-cache
, the build succeeds. When bundler-cache
is true, the xcodebuild
step fails:
xcodebuild test
Error: spawn xcpretty ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:282:[19](https://github.com/squareup/wallet/actions/runs/3318014846/jobs/5481488702#step:7:20))
at onErrorNT (node:internal/child_process:477:16)
at processTicksAndRejections (node:internal/process/task_queues:83:[21](https://github.com/squareup/wallet/actions/runs/3318014846/jobs/5481488702#step:7:22))
I lightly suspect it's because setup-ruby
changes the bundle configuration. Is there a way for xcodebuild
to detect that xcpretty
was installed via bundle
and to run bundle exec xcpretty
instead?
Where possible I prefer to test without an Xcode project, but the Xcode selection feature of this action isn't usable without also creating an Xcode project and using xcodebuild
to run the tests.
Given the name of the project I'm not sure if a select-only option would be appropriate for this action?
I have my own action that updates the Xcode version used within actions but would prefer to use only this action. If this would be an acceptable feature I'd be willing to contribute to the project.
https://github.blog/changelog/2020-04-15-github-actions-new-workflow-features/
So the action might look like:
jobs:
foo:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.xcode-matrix.outputs.matrix }}
steps:
- uses: mxcl/xcode-matrix
id: xcode-matrix
with:
swift: 5.0 5.1 5.2 5.3 5.4 5.5
And then can be consumed in a subsequent job:
jobs:
bar:
needs: foo
strategy:
matrix: ${{ jobs.foo.outputs.matrix }}
runs-on: ${{ matrix.os }}
steps:
- uses: mxcl/xcodebuild
with:
xcode: ${{ matrix.xcode }}
Note this requires the action to have JSON files on versions that are generated daily via a scheduled workflow since we cannot determine the matrix inside any particular runs-on
image. Hence the above uses ubuntu.
Note not sure how to do eg. platform
matrix this way.
Swift 5.4 was included with Xcode 12.5. I suspect this is failing because "5.4" is not "5.4.0", a valid semantic version. My workflow requests swift: ~5.4
and runs-on: macos-11
.
8
/usr/bin/mdfind kMDItemCFBundleIdentifier = com.apple.dt.Xcode
9
/Applications/Xcode_12.5.app
10
/Applications/Xcode_11.7.app
11
/Applications/Xcode_12.3.app
12
/Applications/Xcode_12.4.app
13
/Applications/Xcode_13.0.app
14
/usr/bin/mdls -raw -name kMDItemVersion /Applications/Xcode_12.5.app
15
and]/usr/bin/mdls -raw -name kMDItemVersion /Applications/Xcode_11.7.app
16
and]/usr/bin/mdls -raw -name kMDItemVersion /Applications/Xcode_12.3.app
17
and]/usr/bin/mdls -raw -name kMDItemVersion /Applications/Xcode_12.4.app
18
and]/usr/bin/mdls -raw -name kMDItemVersion /Applications/Xcode_13.0.app
19
and]/usr/bin/swift --version
20
/usr/bin/swift --version
21
/usr/bin/swift --version
22
/usr/bin/swift --version
23
/usr/bin/swift --version
24
2021-06-17 17:08:01.601 xcodebuild[1266:23832] [MT] DVTPlugInManager: Required plug-in compatibility UUID 42E1F17B-27B3-4DE8-92A8-DC76BA4F5921 for DVTCoreGlyphs.framework (com.apple.dt.DVTCoreGlyphs) not present
25
2021-06-17 17:08:01.601 xcodebuild[1266:23832] [MT] DVTPlugInManager: Required plug-in compatibility UUID 42E1F17B-27B3-4DE8-92A8-DC76BA4F5921 for DVTCoreGlyphs.framework (com.apple.dt.DVTCoreGlyphs) not present
26
Apple Swift version 5.2.4 (swiftlang-1103.0.32.9 clang-1103.0.32.53)
27
Target: x86_64-apple-darwin20.5.0
28
2021-06-17 17:08:06.416 xcodebuild[1570:25368] [MT] DVTPlugInManager: Required plug-in compatibility UUID 42E1F17B-27B3-4DE8-92A8-DC76BA4F5921 for DVTCoreGlyphs.framework (com.apple.dt.DVTCoreGlyphs) not present
29
2021-06-17 17:08:06.416 xcodebuild[1570:25368] [MT] DVTPlugInManager: Required plug-in compatibility UUID 42E1F17B-27B3-4DE8-92A8-DC76BA4F5921 for DVTCoreGlyphs.framework (com.apple.dt.DVTCoreGlyphs) not present
30
Apple Swift version 5.4 (swiftlang-1205.0.26.9 clang-1205.0.19.55)
31
Target: x86_64-apple-darwin20.5.0
32
Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)
33
Target: x86_64-apple-darwin20.5.0
34
Apple Swift version 5.3.2 (swiftlang-1200.0.45 clang-1200.0.32.28)
35
Target: x86_64-apple-darwin20.5.0
36
swift-driver version: 1.26 Apple Swift version 5.5 (swiftlang-1300.0.19.104 clang-1300.0.18.4)
37
Target: x86_64-apple-macosx11.0
38
Error: Error: No Xcode with Swift ~> ~5.4
39
swift-driver version: 1.26
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.