xcode - Github Actions:xcodebuild 由于服务器指纹而失败
问题描述
我正在尝试使用 Github Actions 构建一个 macOS 应用程序。这已经很好地工作了,直到我将我的依赖项迁移到 Swift 包管理器。现在我在构建我的应用程序时收到以下错误:
xcodebuild: error: Could not resolve package dependencies:
The server SSH fingerprint failed to verify.
我有一个私有 GitHub 存储库作为我的应用程序中的依赖项,使用 ssh 位置添加为 Swift 包。因此,我需要在Set up ssh-agent
步骤中为依赖项添加我的 ssh 密钥。使用步骤手动克隆存储库git clone
工作正常,但我需要让它与 xcodebuild 一起使用才能成功构建我的应用程序。
工作流文件
name: Main
on:
push:
tags:
- 'v*.*.*'
jobs:
build:
name: Release
runs-on: macOS-latest
steps:
- name: Checkout
uses: actions/checkout@master
with:
fetch-depth: 1
- name: Set up ssh-agent
uses: yakuhzi/action-ssh-agent@v1
with:
public: ${{ secrets.SSH_PUBLIC_KEY }}
private: ${{ secrets.SSH_PRIVATE_KEY }}
- name: Build application
run: |
sudo xcode-select -switch /Applications/Xcode_11.app
xcodebuild -project Application.xcodeproj -scheme Application -configuration Release -derivedDataPath $HOME/Application build
解决方案
最后我想通了。这似乎是 Xcode 11 ( https://developer.apple.com/documentation/xcode_release_notes/xcode_11_release_notes ) 中的一个已知问题。
感谢这篇文章中的 Dosium ( https://discuss.bitrise.io/t/xcode-11-resolving-packages-fails-with-ssh-fingerprint/10388 ),我能够让它工作。
解决方案是在运行 xcodebuild 之前运行以下命令:
for ip in $(dig @8.8.8.8 github.com +short); do ssh-keyscan github.com,$ip; ssh-keyscan $ip; done 2>/dev/null >> ~/.ssh/known_hosts
推荐阅读
- kubernetes - Kong Ingress 控制器在家
- java - 运行 Kotlin jar 文件
- r - 如何根据另一个输入的值最大化 RShiny 数字输入的值?
- python - If statement throws TemplateSyntaxError Invalid block tag on line 127: 'else', expected 'empty' or 'endfor'
- ruby-on-rails - HTTP 请求在 Postman 中有效,但在 Ruby 中无效(502 错误)
- python - JSON Payload 的请求格式不熟悉
- python - “哪个”无法找到使用 pip (WSL) 安装的软件包
- mips - 继续尝试在 0x00400098 处执行非指令
- swift - 我可以在 API 的后端使用 Swift 吗?
- python - 如何保存加载的模块?