Search code examples
iosswiftxcodecontinuous-integrationbitrise

Adding Xcode Github Account via CLI


I'm attempting to build my iOS app on bitrise.io. This app uses an SPM package which is hosted in a private github repo. The repo is not able to be made public.

Locally the builds work, they also work locally with fastlane and the bitrise cli. When I run them on the remote pipeline, I get the following error:

xcodebuild: error: Could not resolve package dependencies:
  Failed to clone repository https://github.com/USERNAME_REDACTED/REPO_NAME_REDACTED:
    Cloning into bare repository '/Users/vagrant/Library/Developer/Xcode/DerivedData/ORG_NAME_REDACTED/SourcePackages/repositories/REPO_NAME_REDACTED-d35b1ef7'...
    fatal: could not read Username for 'https://github.com': terminal prompts disabled

My understanding as to why this does not work, is because the Xcode instance on the remote pipeline machine, does not have a GitHub account added. I am able to do this using the Xcode GUI locally by going to Xcode > Preferences > Accounts as you can see below

Xcode Add Account

The problem here is that I need to figure out a way to do this via script for the remote by providing a username and personal access token. Thus far I've spent about 20 hours looking through xcodebuild docs and messing around with different configs however I've not had any luck getting this to work.

Any help is appreciated.


Solution

  • Changing the Xcode project to use ssh to import the module worked for this. I had to also change the remote CI machine to use the system keychain in order to fetch the SSH key.