Search code examples
xcodegitlabfastlaneswift-package-managerbitrise

Bitrise & SPM - How to build private SPM dependencies with Bitrise?


we have

  • xcode project with few swift-package-manager dependencies, but ONE of these dependencies hosted on Gitlab private repo
  • fastlane for build and deliver our app
  • bitrise as CI service

All works fine on local machine - Xcode just ask to fill auth info for Gitlab (login/access-token), then dependencies graph resolves and we can build our project.

But Bitrise fails on gym stage with error below =(

xcodebuild: error: Could not resolve package dependencies: Authentication failed because no credentals were provided.

How to authenticate Gitlab account for Bitrise to process gym stage?


Solution

  • Over past day I tried following approaches:

    • try to change dependency declaration in Package.swift to ssh-style like [email protected]:CompanyName/PackageName.git (I thought xcodebuild can establish ssh connection to fetch private dependency)
    • check gitlab ssh connection via ssh -T [email protected] (connection OK)
    • try to add gitlab hosts as known to ~/.ssh/known_hosts as Apple proposes here
    • connect via ssh to running Bitrise build to setup ssh setttings manually in runtime
    • shuffle these approaches in different order

    And nothing helps. Until I tried following one

    • Authenticate host with netrc

    There is special build step in Workflow editor where you can setup gitlab access data. Set this step just before SPM resolve stage fires and annoying error about missing credentials gone.