Skip to content

ci: add SPM resolve step with retry, --triple flags, and cache - #5166

Merged
m13v merged 1 commit into
mainfrom
ci/spm-resolve-retry
Feb 26, 2026
Merged

m13v merged 1 commit into
mainfrom
ci/spm-resolve-retry

Conversation

@m13v

@m13v m13v commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

Problem

Build #12 failed at "Build Swift app (arm64 + x86_64)" on a fresh Codemagic Mac mini M2:

ERROR: arm64 binary not found at Desktop/.build/arm64-apple-macosx/release/Omi Computer
artifacts
checkouts
repositories
workspace-state.json

Root cause: SPM needs to download ~673MB of binary artifacts (Firebase, Sentry, Sparkle xcframeworks) on a fresh machine. When xcrun swift build --arch arm64 runs, it tries to download everything and compile in a single step. The download failed/aborted mid-way (375MB of 673MB downloaded), leaving no arm64-apple-macosx/ directory — so compilation never started. Without set -e, the script continued to the binary existence check and exited with 1.

Build #11 succeeded only because that machine had a warm SPM cache from previous builds.

Fix

  1. New "Resolve SPM packages" step — runs xcrun swift package resolve before building, with a 3-attempt retry loop. This pre-downloads all binary artifacts. If the first attempt fails partway, the second attempt resumes from where it left off (SPM checkpoints downloads).

  2. --triple instead of --arch — switches from xcrun swift build --arch arm64 to --triple arm64-apple-macosx. This matches the local release.sh behavior and ensures the output binary always lands in .build/arm64-apple-macosx/release/ regardless of the machine's native architecture (on native M2, --arch arm64 may use the release/ symlink path).

  3. SPM cache — adds ~/Library/Caches/org.swift.swiftpm to Codemagic's build cache so binary xcframeworks are not re-downloaded on every subsequent build.

Result

  • Fresh machine: resolve step downloads packages with retry, then both builds compile using already-cached artifacts
  • Warm machine: resolve is instant (already cached), builds proceed normally

🤖 Generated with Claude Code

- Add "Resolve SPM packages" step with 3-attempt retry loop before
  building, so binary artifact downloads (~673MB) complete reliably
  on fresh Codemagic machines before compilation starts
- Switch --arch arm64/x86_64 to --triple arm64/x86_64-apple-macosx
  for explicit, predictable output directories (matches local release.sh)
- Add ~/Library/Caches/org.swift.swiftpm to Codemagic cache so
  subsequent builds skip re-downloading binary xcframeworks

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@m13v
m13v merged commit ff8db3b into main Feb 26, 2026
1 check passed
@m13v
m13v deleted the ci/spm-resolve-retry branch February 26, 2026 16:39
@greptile-apps

greptile-apps Bot commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

Added three complementary improvements to prevent SPM download failures on fresh CI machines:

  • Pre-resolution step with 3-attempt retry and 15s backoff downloads ~673MB of binary artifacts (Firebase, Sentry, Sparkle) before compilation, allowing SPM to checkpoint and resume partial downloads
  • --triple flags replace --arch to guarantee binaries land in arch-specific paths (arm64-apple-macosx/release/, x86_64-apple-macosx/release/) regardless of host architecture
  • SPM cache (~/Library/Caches/org.swift.swiftpm) prevents re-downloading artifacts on subsequent builds

The retry logic correctly handles all failure cases, breaking on success and exiting with error after 3 failed attempts. Error handling includes diagnostic output showing artifact count after resolution.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • Well-architected fix for a documented build failure with proper retry logic, correct flag usage, and appropriate caching. Changes are isolated to CI configuration with no impact on application code
  • No files require special attention

Important Files Changed

Filename Overview
codemagic.yaml Adds SPM cache, pre-resolution step with retry logic, and switches to --triple flags for reliable builds on fresh machines

Last reviewed commit: e44fa03

Glucksberg pushed a commit to Glucksberg/omi-local that referenced this pull request Apr 28, 2026
…Hardware#5166)

## Problem

Build BasedHardware#12 failed at \"Build Swift app (arm64 + x86_64)\" on a fresh
Codemagic Mac mini M2:

```
ERROR: arm64 binary not found at Desktop/.build/arm64-apple-macosx/release/Omi Computer
artifacts
checkouts
repositories
workspace-state.json
```

Root cause: SPM needs to download ~673MB of binary artifacts (Firebase,
Sentry, Sparkle xcframeworks) on a fresh machine. When `xcrun swift
build --arch arm64` runs, it tries to download everything **and
compile** in a single step. The download failed/aborted mid-way (375MB
of 673MB downloaded), leaving no `arm64-apple-macosx/` directory — so
compilation never started. Without `set -e`, the script continued to the
binary existence check and exited with 1.

Build BasedHardware#11 succeeded only because that machine had a warm SPM cache from
previous builds.

## Fix

1. **New \"Resolve SPM packages\" step** — runs `xcrun swift package
resolve` before building, with a 3-attempt retry loop. This
pre-downloads all binary artifacts. If the first attempt fails partway,
the second attempt resumes from where it left off (SPM checkpoints
downloads).

2. **`--triple` instead of `--arch`** — switches from `xcrun swift build
--arch arm64` to `--triple arm64-apple-macosx`. This matches the local
`release.sh` behavior and ensures the output binary **always** lands in
`.build/arm64-apple-macosx/release/` regardless of the machine's native
architecture (on native M2, `--arch arm64` may use the `release/`
symlink path).

3. **SPM cache** — adds `~/Library/Caches/org.swift.swiftpm` to
Codemagic's build cache so binary xcframeworks are not re-downloaded on
every subsequent build.

## Result

- Fresh machine: resolve step downloads packages with retry, then both
builds compile using already-cached artifacts
- Warm machine: resolve is instant (already cached), builds proceed
normally

🤖 Generated with [Claude Code](https://claude.com/claude-code)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant