Fix Swift snapshot build: don't reference withAUAudioUnit#1039
Merged
Conversation
…ilds) The Swift main-snapshot build (newer compiler + current stable macOS SDK) fails with "cannot find 'withAUAudioUnit' in scope": `#if compiler(>=6.4)` selects the `withAUAudioUnit` branch, but that symbol only exists in the macOS 27 SDK, and the snapshot toolchain pairs a >=6.4 compiler with the macOS 26 SDK. There's no reliable compile-time SDK / API-presence check in Swift (`canImport(_:_version:)` doesn't distinguish the SDKs), so drop `withAUAudioUnit` and reach `auAudioUnit` — which exists on every SDK — under `if #available(macOS 13.0)`, falling back to `LKObjCHelpers` below macOS 13. `#if compiler(>=6.4)` is kept only so older toolchains use the property directly (no ObjC shim) down to macOS 10.13. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
|
|
hiroshihorie
approved these changes
Jun 10, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #1038. The nightly Swift Snapshot Build (
.github/workflows/swift-snapshot.yaml) fails onmainafter #1038:Root cause
That workflow runs
swift buildwith the main-snapshot compiler (so#if compiler(>=6.4)is true) but against the runner's current stable SDK (macOS 26 —latestXcode, since 27 is still beta).withAUAudioUnitonly exists in the macOS 27 SDK, so thecompiler(>=6.4)branch compiles the symbol in, but the SDK doesn't have it.The deeper issue:
#if compiler(>=6.4)is a compiler check used as an SDK proxy. That holds for shipping Xcode (compiler and SDK ship together) but not for the snapshot toolchain (new compiler + stable SDK). There's no reliable compile-time SDK/API-presence check in Swift —canImport(AVFAudio, _version:)reports the same version in both SDKs, and keying off a new-in-27 framework would be fragile.Fix
Drop
withAUAudioUnitand reachauAudioUnit— which exists on every SDK (only its Swift availability annotation differs) — underif #available(macOS 13.0), falling back toLKObjCHelpersbelow macOS 13.#if compiler(>=6.4)is kept so older toolchains (Xcode 16.4 / 26.5) use the property directly with no ObjC shim down to macOS 10.13.This compiles on every compiler/SDK combination, including the snapshot's newer-compiler + macOS 26 SDK.
Testing
swift build --build-system nativewith the Xcode 27 compiler + macОS 26 SDK (reproduces the snapshot combo): Build complete ✅ (was:cannot find 'withAUAudioUnit').No user-facing behavior change (the
auAudioUnitaccess is functionally identical), so no changeset.🤖 Generated with Claude Code