Skip to content

ci(preview): use real macOS SDK for cross-compilation - #403

Merged
donbeave merged 4 commits into
mainfrom
ci/macos-sdk-cross-compile
May 20, 2026
Merged

donbeave merged 4 commits into
mainfrom
ci/macos-sdk-cross-compile

Conversation

@donbeave

Copy link
Copy Markdown
Member

Summary

Replaces fake TBD stub approach with the real macOS SDK from joseluisq/macosx-sdks.

Root cause confirmed: cargo-zigbuild cannot resolve Apple frameworks without the actual SDK — Zig only ships C stdlib stubs, not framework stubs (ziglang/zig#1349, still open). Fake .tbd stubs are either rejected or don't contain the symbol exports Zig's linker needs.

Fix: Download MacOSX15.5.sdk (~75 MB compressed, cached via actions/cache keyed on SDK version) and set SDKROOT. Zig passes SDKROOT as -isysroot to the MachO linker, which resolves CoreFoundation and all other Apple frameworks from the real framework stubs in the SDK. This is the same approach used by Wails v3 for macOS cross-compilation from Linux.

Hard-rule callout

CI-only change. No schema, host-side, or user-visible changes.

What's deferred

Code-signing for macOS binaries — binary will not be signed, macOS Gatekeeper may prompt on first launch. Acceptable for developer-targeted preview.

🤖 Generated with Claude Code

donbeave and others added 4 commits May 20, 2026 01:40
-undefined dynamic_lookup defers symbol resolution to runtime but Zig's
MachO linker still validates that the framework directory exists in the
search paths before deferring. With no -F paths configured the linker
rejects -framework CoreFoundation outright.

Create a minimal CoreFoundation.tbd stub (empty exports, correct
install-name) and add its parent dir via -F so the linker's framework-
exists check passes. All actual CoreFoundation symbols resolve at runtime
on real macOS where the framework is always present.

Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Alexey Zhokhov <alexey@zhokhov.com>
cargo-zigbuild cannot resolve Apple frameworks (CoreFoundation, etc.)
without the actual SDK — Zig only ships C stdlib stubs, not framework
stubs (ziglang/zig#1349). Fake TBD stubs are rejected by Zig's linker.

Fix: download MacOSX15.5.sdk from joseluisq/macosx-sdks (~75 MB, cached
between runs via actions/cache) and set SDKROOT. Zig passes SDKROOT as
-isysroot to the linker, which resolves CoreFoundation and all other
Apple frameworks from the real SDK framework stubs.

Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Alexey Zhokhov <alexey@zhokhov.com>
Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Alexey Zhokhov <alexey@zhokhov.com>
MacOSX26.1.sdk defaults to macOS 26 minimum deployment target.
Binaries built against it wouldn't run on macOS 12–25 without this.
Setting 12.0 keeps the preview binary compatible with all reasonably
modern macOS while still using the latest SDK for compilation.

Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Alexey Zhokhov <alexey@zhokhov.com>
@donbeave
donbeave force-pushed the ci/macos-sdk-cross-compile branch from 1731238 to e5aca32 Compare May 20, 2026 01:40
@donbeave
donbeave merged commit fb0fb7e into main May 20, 2026
18 checks passed
@donbeave
donbeave deleted the ci/macos-sdk-cross-compile branch May 20, 2026 01:41
donbeave added a commit that referenced this pull request Jun 7, 2026
## Summary

Replaces fake TBD stub approach with the real macOS SDK from
[joseluisq/macosx-sdks](https://github.com/joseluisq/macosx-sdks).

**Root cause confirmed:** `cargo-zigbuild` cannot resolve Apple
frameworks without the actual SDK — Zig only ships C stdlib stubs, not
framework stubs
([ziglang/zig#1349](ziglang/zig#1349), still
open). Fake `.tbd` stubs are either rejected or don't contain the symbol
exports Zig's linker needs.

**Fix:** Download `MacOSX15.5.sdk` (~75 MB compressed, cached via
`actions/cache` keyed on SDK version) and set `SDKROOT`. Zig passes
`SDKROOT` as `-isysroot` to the MachO linker, which resolves
CoreFoundation and all other Apple frameworks from the real framework
stubs in the SDK. This is the same approach used by Wails v3 for macOS
cross-compilation from Linux.

## Hard-rule callout

CI-only change. No schema, host-side, or user-visible changes.

## What's deferred

Code-signing for macOS binaries — binary will not be signed, macOS
Gatekeeper may prompt on first launch. Acceptable for developer-targeted
preview.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Alexey Zhokhov <alexey@zhokhov.com>
Co-authored-by: Claude <noreply@anthropic.com>
donbeave added a commit that referenced this pull request Jun 24, 2026
## Summary

Replaces fake TBD stub approach with the real macOS SDK from
[joseluisq/macosx-sdks](https://github.com/joseluisq/macosx-sdks).

**Root cause confirmed:** `cargo-zigbuild` cannot resolve Apple
frameworks without the actual SDK — Zig only ships C stdlib stubs, not
framework stubs
([ziglang/zig#1349](ziglang/zig#1349), still
open). Fake `.tbd` stubs are either rejected or don't contain the symbol
exports Zig's linker needs.

**Fix:** Download `MacOSX15.5.sdk` (~75 MB compressed, cached via
`actions/cache` keyed on SDK version) and set `SDKROOT`. Zig passes
`SDKROOT` as `-isysroot` to the MachO linker, which resolves
CoreFoundation and all other Apple frameworks from the real framework
stubs in the SDK. This is the same approach used by Wails v3 for macOS
cross-compilation from Linux.

## Hard-rule callout

CI-only change. No schema, host-side, or user-visible changes.

## What's deferred

Code-signing for macOS binaries — binary will not be signed, macOS
Gatekeeper may prompt on first launch. Acceptable for developer-targeted
preview.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Alexey Zhokhov <alexey@zhokhov.com>
Co-authored-by: Claude <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