[英]how to select xcode version in fastlane when using github actions
I am using fastlane in github actions to build my project, this is my github actions script:我在 github 动作中使用 fastlane 来构建我的项目,这是我的 github 动作脚本:
name: Cruise-CI
on:
push:
branches: [ main ]
jobs:
build:
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- uses: actions/setup-java@v1
with:
java-version: '12.x'
- uses: subosito/flutter-action@v1
with:
flutter-version: '1.22.5'
- name: Select Xcode version
run: sudo xcode-select -s '/Applications/Xcode_12.1.app/Contents/Developer'
- name: Bundle install
run: cd ./ios && bundle install && bundle update fastlane
- name: Install tools
run: |
flutter precache
flutter pub get
cd ./ios && pod repo update && pod install
#- run: flutter pub get
#- run: flutter build apk
#- run: flutter build ios --release --no-codesign
- name: Setup SSH Keys and known_hosts for fastlane match
run: |
SSH_PATH="$HOME/.ssh"
mkdir -p "$SSH_PATH"
touch "$SSH_PATH/known_hosts"
echo "$PRIVATE_KEY" > "$SSH_PATH/id_rsa"
chmod 700 "$SSH_PATH"
ssh-keyscan github.com >> ~/.ssh/known_hosts
chmod 600 "$SSH_PATH/known_hosts"
chmod 600 "$SSH_PATH/id_rsa"
eval $(ssh-agent)
ssh-add "$SSH_PATH/id_rsa"
env:
PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Deploy to TestFlight/PGY
run: |
cd ./ios && bundle exec fastlane beta
env:
APPLE_ID: ${{ secrets.APPLE_ID }}
GIT_URL: ${{ secrets.GIT_URL }}
PGY_USER_KEY: ${{ secrets.PGY_USER_KEY }}
PGY_API_KEY: ${{ secrets.PGY_API_KEY }}
TEAM_ID: ${{ secrets.TEAM_ID }}
ITC_TEAM_ID: ${{ secrets.ITC_TEAM_ID }}
FASTLANE_USER: ${{ secrets.FASTLANE_USER }}
FASTLANE_PASSWORD: ${{ secrets.FASTLANE_PASSWORD }}
FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD: ${{ secrets.FASTLANE_APPLE_APPLICATION_SPECIFIC_PASSWORD }}
FASTLANE_SESSION: ${{ secrets.FASTLANE_SESSION }}
MATCH_PASSWORD: ${{ secrets.MATCH_PASSWORD }}
MATCH_KEYCHAIN_NAME: ${{ secrets.MATCH_KEYCHAIN_NAME }}
MATCH_KEYCHAIN_PASSWORD: ${{ secrets.MATCH_KEYCHAIN_PASSWORD }}
DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS: ${{ secrets.DELIVER_ITMSTRANSPORTER_ADDITIONAL_UPLOAD_PARAMETERS }}
and this is my Fastfile script:这是我的 Fastfile 脚本:
update_fastlane
default_platform(:ios)
platform :ios do
desc "Push a new beta build to pgy"
before_all do
ENV["CACHE_GIT_URL"] = ENV["GIT_URL"]
end
lane :beta do
xcode_select('/Applications/Xcode_12.1.app')
if is_ci
create_keychain(
name: ENV['MATCH_KEYCHAIN_NAME'],
password: ENV["MATCH_KEYCHAIN_PASSWORD"],
default_keychain: true,
unlock: true,
timeout: 3600,
lock_when_sleeps: false
)
end
match(
app_identifier: ENV["APP_IDENTIFIER"],
git_url: ENV["GIT_URL"],
type: "adhoc",
readonly: is_ci,
keychain_name: ENV['MATCH_KEYCHAIN_NAME'],
keychain_password: ENV["MATCH_KEYCHAIN_PASSWORD"]
)
build_app(
workspace: "Runner.xcworkspace",
scheme: "Runner",
export_method: "ad-hoc"
)
pgyer(
api_key: ENV['PGY_API_KEY'],
user_key: ENV['PGY_USER_KEY']
)
end
end
but when runs in github actions shows this error :但是在 github 中运行时,操作会显示此错误:
** ARCHIVE FAILED **
The following build commands failed:
PhaseScriptExecution Run\ Script /Users/runner/Library/Developer/Xcode/DerivedData/Runner-gzzbtgmsqethlzedjqlbspydxjjv/Build/Intermediates.noindex/ArchiveIntermediates/Runner/IntermediateBuildFilesPath/Runner.build/Release-iphoneos/Runner.build/Script-9740EEB61CF901F6004384FC.sh
(1 failure)
[04:51:35]: Exit status: 65
[04:51:35]:
[04:51:35]: Maybe the error shown is caused by using the wrong version of Xcode
[04:51:35]: Found multiple versions of Xcode in '/Applications/'
[04:51:35]: Make sure you selected the right version for your project
[04:51:35]: This build process was executed using '/Applications/Xcode_12.1.app'
[04:51:35]: If you want to update your Xcode path, either
[04:51:35]:
[04:51:35]: - Specify the Xcode version in your Fastfile
[04:51:35]: ▸ xcversion(version: "8.1") # Selects Xcode 8.1.0
[04:51:35]:
[04:51:35]: - Specify an absolute path to your Xcode installation in your Fastfile
[04:51:35]: ▸ xcode_select "/Applications/Xcode8.app"
[04:51:35]:
[04:51:35]: - Manually update the path using
[04:51:35]: ▸ sudo xcode-select -s /Applications/Xcode.app
[04:51:35]:
+---------------+------------------------------+
| Build environment |
+---------------+------------------------------+
| xcode_path | /Applications/Xcode_12.1.app |
| gym_version | 2.171.0 |
| export_method | ad-hoc |
| sdk | iPhoneOS14.1.sdk |
+---------------+------------------------------+
[04:51:35]: ▸ ../../../hostedtoolcache/flutter/1.22.5-stable/x64/packages/flutter/lib/src/widgets/scroll_view.dart:588:9: Context: Found this candidate, but the arguments don't match.
[04:51:35]: ▸ const CustomScrollView({
[04:51:35]: ▸ ^^^^^^^^^^^^^^^^
[04:51:35]: ▸ Command PhaseScriptExecution failed with a nonzero exit code
[04:51:35]:
[04:51:35]: ⬆️ Check out the few lines of raw `xcodebuild` output above for potential hints on how to solve this error
[04:51:35]: 📋 For the complete and more detailed error log, check the full log at:
[04:51:35]: 📋 /Users/runner/Library/Logs/gym/Runner-Runner.log
[04:51:35]:
[04:51:35]: Looks like fastlane ran into a build/archive error with your project
[04:51:35]: It's hard to tell what's causing the error, so we wrote some guides on how
[04:51:35]: to troubleshoot build and signing issues: https://docs.fastlane.tools/codesigning/getting-started/
[04:51:35]: Before submitting an issue on GitHub, please follow the guide above and make
[04:51:35]: sure your project is set up correctly.
[04:51:35]: fastlane uses `xcodebuild` commands to generate your binary, you can see the
[04:51:35]: the full commands printed out in yellow in the above log.
[04:51:35]: Make sure to inspect the output above, as usually you'll find more error information there
[04:51:35]:
+------------------------------------+--------------------------------------------------------+
| Lane Context |
+------------------------------------+--------------------------------------------------------+
| DEFAULT_PLATFORM | ios |
| PLATFORM_NAME | ios |
| LANE_NAME | ios beta |
| KEYCHAIN_PATH | ~/Library/Keychains/*** |
| ORIGINAL_DEFAULT_KEYCHAIN | "/Users/runner/Library/Keychains/login.keychain-db" |
| SIGH_PROFILE_TYPE | ad-hoc |
| MATCH_PROVISIONING_PROFILE_MAPPING | {"com.earth.dolphin"=>"match AdHoc com.earth.dolphin"} |
+------------------------------------+--------------------------------------------------------+
[04:51:35]: Error building the application - see the log above
I have already tried to specify the version of xcode in fastlane file like this:我已经尝试在 fastlane 文件中指定 xcode 的版本,如下所示:
xcode_select('/Applications/Xcode_12.1.app')
but still not work, what should I do to fix this?但还是不行,我该怎么做才能解决这个问题? I also tried to change the xcode version to 12.3 follow this doc like this:我还尝试将 xcode 版本更改为 12.3 遵循此文档,如下所示:
xcode_select('/Applications/Xcode_12.3.app')
still now work.现在还在工作。
You are running on the latest MacOS image (which, at time of writing, is macos-10.15
with Xcode 12.4.0.0.1.1610135815
—see installed tools ):您正在最新的 MacOS 映像上运行(在撰写本文时,它是带有 Xcode 12.4.0.0.1.1610135815
的macos-10.15
- 请参阅已安装的工具):
jobs:
build:
runs-on: macos-latest
But you are trying to select a specific version of Xcode to use:但是您正在尝试 select 特定版本的 Xcode 使用:
- name: Select Xcode version
run: sudo xcode-select -s '/Applications/Xcode_12.1.app/Contents/Developer'
The latest MacOS version (and the installed Xcode version) are liable to change if you use the -latest
suffix when specifying the runs-on
image.如果您在指定runs-on
映像时使用-latest
后缀,则最新的 MacOS 版本(以及已安装的 Xcode 版本)可能会发生变化。
Ensure that your MacOS and Xcode versions are compatible or just remove the Select Xcode version
step entirely.确保您的 MacOS 和 Xcode 版本兼容,或者完全删除Select Xcode version
步骤。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.