Skip to content

fix(ci): Xcode Cloud — xcodebuild fails to resolve SwiftPM packages (no committed Package.resolved at workspace) #96

Closed

Description

@wei18

Symptom

Build #9 (after #95 fixed CI_TEAM_ID) advances past Signing + tuist generate, then fails:

xcodebuild: error: Could not resolve package dependencies:
  a resolved file is required when automatic dependency resolution is disabled
  and should be placed at /Volumes/workspace/repository/Sudoku.xcworkspace/xcshareddata/swiftpm/Package.resolved.
  Running resolver because the following dependencies were added:
  'swift-package-manager-google-mobile-ads'

Exit 74.

Root cause

Tuist generates Sudoku.xcworkspace, then invokes xcodebuild -resolvePackageDependencies -workspace ... -list with -disableAutomaticPackageResolution (Tuist 4 default for safety). The workspace has no committed Package.resolved (gitignored — workspace itself is generated), so resolution fails.

The SudokuKit package's own Packages/SudokuKit/Package.resolved IS committed and pins the AdMob version, but that's for the SwiftPM-only path; xcodebuild's workspace resolver looks at Sudoku.xcworkspace/xcshareddata/swiftpm/Package.resolved.

Fix

In ci_scripts/ci_post_clone.sh, after tuist generate --no-open, run an explicit xcodebuild resolve that enables automatic resolution:

# 3.3) Resolve SwiftPM packages at the workspace level (Tuist disables
# automatic resolution; we re-enable for first-time CI fetches)
xcodebuild -resolvePackageDependencies \
    -workspace Sudoku.xcworkspace \
    -scheme Sudoku \
    -clonedSourcePackagesDirPath "${CI_DERIVED_DATA_PATH:-DerivedData}/SourcePackages" \
    -onlyUsePackageVersionsFromResolvedFile NO

Reference: Apple's xcodebuild docs + Tuist's CI guide mention this pattern for first-fetch.

-onlyUsePackageVersionsFromResolvedFile NO allows xcodebuild to fetch + write a new Package.resolved when none exists.

Alternative considered

  • Commit workspace Package.resolved — workspace is generated by tuist generate, so the file would always be stale relative to Package.swift edits. Rejected.
  • Use SudokuKit Package.resolved — different location; xcodebuild won't pick it up at the workspace path.

Acceptance

Out of scope

  • Caching ~/Library/Caches/org.swift.swiftpm/ between builds (backlog)
  • Switching off Tuist (out of scope)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions