Skip to content

fix: build universal binary (arm64 + x86_64) - #1

Open
beznazwiska wants to merge 1 commit into
studiogo:mainfrom
beznazwiska:fix/universal-binary
Open

fix: build universal binary (arm64 + x86_64)#1
beznazwiska wants to merge 1 commit into
studiogo:mainfrom
beznazwiska:fix/universal-binary

Conversation

@beznazwiska

Copy link
Copy Markdown

Problem

build.sh hardcodes -target arm64-apple-macos13.0, producing an Apple Silicon-only binary. On Intel Macs the app fails to launch with:

bad CPU type in executable

The open command returns NSOSStatusErrorDomain Code=-10661, giving no clear indication that architecture is the root cause.

Solution

Build separate binaries for both architectures and merge them into a single universal binary via lipo:

swiftc -target arm64-apple-macos13.0 ...  → ClaudePeakHours_arm64
swiftc -target x86_64-apple-macos13.0 ... → ClaudePeakHours_x86_64
lipo -create *_arm64 *_x86_64 -output ClaudePeakHours

Additional improvements:

  • Extracted source files and frameworks into variables (DRY)
  • Added architecture info to build output for verification
  • Cleaned up intermediate binaries after lipo

Testing

Verified on macOS 13.7 Ventura (Intel x86_64):

  • build.sh completes successfully
  • Output binary contains both architectures: Mach-O universal binary with 2 architectures: [x86_64] [arm64]
  • App launches and runs correctly in menu bar
  • No changes to Swift source code — build script only

Compatibility

  • No breaking changes for Apple Silicon users
  • install.sh works unchanged (calls build.sh internally)
  • Pre-built releases would need to ship universal binaries separately

The previous build script hardcoded `-target arm64-apple-macos13.0`,
producing an Apple Silicon-only binary. Intel Macs failed with
"bad CPU type in executable" (NSError -10661).

This change compiles for both architectures separately and merges them
via `lipo` into a single universal binary. Verified on macOS 13.7
Ventura (Intel).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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