Skip to content

Fix: normalize arm64 binary path after --arch arm64 build on native M2 host#5147

Merged
m13v merged 1 commit intomainfrom
fix/arm64-binary-path
Feb 26, 2026
Merged

Fix: normalize arm64 binary path after --arch arm64 build on native M2 host#5147
m13v merged 1 commit intomainfrom
fix/arm64-binary-path

Conversation

@m13v
Copy link
Copy Markdown
Contributor

@m13v m13v commented Feb 26, 2026

Problem

On Codemagic mac_mini_m2 with Xcode 16.4, xcrun swift build --arch arm64 outputs the binary to .build/release/ (the native arch path) instead of .build/arm64-apple-macosx/release/. This caused the "Create universal app bundle" step to fail with ERROR: Missing built binaries every time.

The x86_64 cross-compilation correctly outputs to .build/x86_64-apple-macosx/release/, so only the arm64 binary was missing.

Fix

After the arm64 build, detect if the binary landed in release/ instead of arm64-apple-macosx/release/ and copy it to the expected location. Also copies Sparkle.framework and the SPM resource bundle if present.

This is the fourth fix attempt in this release pipeline:

  1. ✅ Group name: omi_desktopdesktop_secrets
  2. ✅ Build flags: --triple--arch
  3. ✅ This fix: normalize arm64 output path

…2 host

On Codemagic mac_mini_m2 with Xcode 16.4, xcrun swift build --arch arm64
outputs the binary to .build/release/ (native arch) instead of the
expected .build/arm64-apple-macosx/release/. This caused 'Create universal
app bundle' to fail with 'ERROR: Missing built binaries'.

After the arm64 build, copy the binary (and Sparkle.framework, resource
bundle) to the arch-specific path if not already there, so downstream
steps find them at the expected location.
@m13v m13v merged commit 6b67b90 into main Feb 26, 2026
1 check passed
@m13v m13v deleted the fix/arm64-binary-path branch February 26, 2026 03:30
@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Feb 26, 2026

Greptile Summary

This PR adds path normalization logic to handle a Swift toolchain quirk on Codemagic's M2 Mac runners. When building with --arch arm64 on native arm64 hardware (M2), Swift outputs binaries to .build/release/ instead of the expected .build/arm64-apple-macosx/release/ directory, breaking the downstream universal binary creation step.

The fix:

  • Detects when the arm64 binary lands in the native arch path instead of the arch-specific path
  • Copies the binary, Sparkle.framework, and resource bundle to the expected location
  • Uses conditional checks to only normalize when needed
  • Includes defensive error handling with || true for optional resources

The logic is sound and includes proper validation - the downstream "Create universal app bundle" step already validates both arch-specific binaries exist, so if this normalization fails, the build will fail explicitly rather than producing a broken artifact.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk - it's a defensive workaround for a known CI toolchain quirk
  • The fix is well-designed with proper conditionals, defensive error handling, and clear documentation. It only activates when needed (binary in wrong location) and preserves existing behavior otherwise. Downstream validation ensures build failures are explicit if normalization doesn't work. This is the third iteration in a series of fixes for the same pipeline, showing incremental problem-solving.
  • No files require special attention

Important Files Changed

Filename Overview
codemagic.yaml Adds defensive path normalization for arm64 builds on M2 hosts - copies binary and resources to expected location when Swift outputs to native arch path

Last reviewed commit: b79d0bd

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a workaround in the Codemagic CI pipeline to handle an inconsistency in the build output path for arm64 architecture on native M2 hosts. The change correctly identifies when the build artifacts are in the wrong location and moves them to the expected path, ensuring downstream steps can find them. My feedback focuses on improving the robustness of the shell script to prevent silent failures.

Comment thread codemagic.yaml
Comment on lines +1994 to +1995
[ -d "Desktop/.build/release/Sparkle.framework" ] && cp -R "Desktop/.build/release/Sparkle.framework" "Desktop/.build/arm64-apple-macosx/release/" || true
[ -d "Desktop/.build/release/Omi Computer_Omi Computer.bundle" ] && cp -R "Desktop/.build/release/Omi Computer_Omi Computer.bundle" "Desktop/.build/arm64-apple-macosx/release/" || true
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The || true construct suppresses exit codes from the cp command. If these assets exist but fail to copy (e.g., due to permissions), this will mask the error and potentially cause more obscure failures in later build steps. It's better to let the script fail immediately if cp encounters an issue. The preceding [ -d ... ] && check already handles the case where the source directory doesn't exist.

            [ -d "Desktop/.build/release/Sparkle.framework" ] && cp -R "Desktop/.build/release/Sparkle.framework" "Desktop/.build/arm64-apple-macosx/release/"
            [ -d "Desktop/.build/release/Omi Computer_Omi Computer.bundle" ] && cp -R "Desktop/.build/release/Omi Computer_Omi Computer.bundle" "Desktop/.build/arm64-apple-macosx/release/"

m13v added a commit that referenced this pull request Feb 26, 2026
## Root Cause

Diagnostic build confirmed: on Codemagic mac_mini_m2 with Xcode 16.4,
`xcrun swift build --arch arm64` outputs to `.build/release/` (native
arch path), NOT `.build/arm64-apple-macosx/release/`. Only the x86_64
cross-compilation uses the arch-specific subdirectory.

## Fix

Update three path references in "Create universal app bundle":
- `ARM64_BINARY`: `.build/release/$BINARY_NAME` 
- `SPARKLE_FW`: `.build/release/Sparkle.framework`
- `SWIFT_BUILD_DIR`: `.build/release`

Also removes the failed normalization attempt from PR #5147 (copying
didn't persist across the x86_64 build step).
Glucksberg pushed a commit to Glucksberg/omi-local that referenced this pull request Apr 28, 2026
…2 host (BasedHardware#5147)

## Problem

On Codemagic mac_mini_m2 with Xcode 16.4, `xcrun swift build --arch
arm64` outputs the binary to `.build/release/` (the native arch path)
instead of `.build/arm64-apple-macosx/release/`. This caused the "Create
universal app bundle" step to fail with `ERROR: Missing built binaries`
every time.

The `x86_64` cross-compilation correctly outputs to
`.build/x86_64-apple-macosx/release/`, so only the arm64 binary was
missing.

## Fix

After the arm64 build, detect if the binary landed in `release/` instead
of `arm64-apple-macosx/release/` and copy it to the expected location.
Also copies `Sparkle.framework` and the SPM resource bundle if present.

This is the fourth fix attempt in this release pipeline:
1. ✅ Group name: `omi_desktop` → `desktop_secrets`
2. ✅ Build flags: `--triple` → `--arch` 
3. ✅ This fix: normalize arm64 output path
Glucksberg pushed a commit to Glucksberg/omi-local that referenced this pull request Apr 28, 2026
…Hardware#5149)

## Root Cause

Diagnostic build confirmed: on Codemagic mac_mini_m2 with Xcode 16.4,
`xcrun swift build --arch arm64` outputs to `.build/release/` (native
arch path), NOT `.build/arm64-apple-macosx/release/`. Only the x86_64
cross-compilation uses the arch-specific subdirectory.

## Fix

Update three path references in "Create universal app bundle":
- `ARM64_BINARY`: `.build/release/$BINARY_NAME` 
- `SPARKLE_FW`: `.build/release/Sparkle.framework`
- `SWIFT_BUILD_DIR`: `.build/release`

Also removes the failed normalization attempt from PR BasedHardware#5147 (copying
didn't persist across the x86_64 build step).
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