首页 > 解决方案 > 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

标签: xcodesshxcodebuildswift-package-managergithub-actions

解决方案


最后我想通了。这似乎是 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


推荐阅读