Resolving Swift Package via Multiple Protocols

This is such a great solution/suggestion/workaround. For the first time my private SwiftPM dependencies resolve in my CI. A quick before_script step in my GitLab CI configuration to call git config and it works :tada:.

swiftpm_build:
  stage: build
  before_script:
    - "git config --global url.$CI_SERVER_PROTOCOL://gitlab-ci-token:$CI_JOB_TOKEN@$CI_SERVER_HOST/.insteadOf git@$CI_SERVER_HOST:"
    - swift package resolve
  script:
    - swift build -c release
  tags:
    - swift-5.0

Then the dark times... xcodebuild. Why xcodebuild? Because that's how you run SwiftPM tests on iOS. I do not make the rules. I just work here.

xcodebuild:
  stage: build
  variables:
    DESTINATION: platform=iOS Simulator,name=iPad Pro (9.7 inch),OS=10.3.1
  before_script:
    - "git config --global url.$CI_SERVER_PROTOCOL://gitlab-ci-token:$CI_JOB_TOKEN@$CI_SERVER_HOST/.insteadOf git@$CI_SERVER_HOST:"
    - xcodebuild -resolvePackageDependencies
  script:
    - xcodebuild -enableCodeCoverage YES -scheme "$XCODE_SCHEME" -destination "$DESTINATION" build-for-testing
  tags:
    - swift-5.0
    - iOS-10.3.1
Resolve Package Graph

Fetching git@private.gitlab.instance.local:group/dependency.git


Resolved source packages:
  SwiftPMProject: /Users/buildbot/SwiftPMProject

xcodebuild: error: Could not resolve package dependencies:
  The repository could not be found. Make sure a valid repository exists at the specified location and try again.

So apparently xcodebuild does its own package resolution outside of Git. :man_shrugging:

So close to nirvana.

Regardless, thanks @monocularvision

1 Like