I am trying to build a macOS app with Github Actions. This already worked very well, until I migrated my dependencies to Swift Package Manager. Now I am getting the following error while building my app:
xcodebuild: error: Could not resolve package dependencies:
The server SSH fingerprint failed to verify.
I have a private GitHub repository as a dependeny in my application added as a Swift Package using a ssh location. Therefore I need to add my ssh key for the dependency in the Set up ssh-agent
step. Manually cloning the repository in a step using git clone
is working fine but I need to get it work with xcodebuild in order to successfully build my app.
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
Finally I figured it out. It seems like its a known issue in Xcode 11 (https://developer.apple.com/documentation/xcode_release_notes/xcode_11_release_notes).
Thanks to Dosium in this post (https://discuss.bitrise.io/t/xcode-11-resolving-packages-fails-with-ssh-fingerprint/10388), I was able to get it work.
The solution is to run the following command before running 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
For CircleCI
:
Adding onto Yakuhzi's answer, here's what the step looks like in Circle Ci's yaml file:
- run:
name: Enable SSH
command: |
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With