Skip to content

Fix Swift snapshot build: don't reference withAUAudioUnit#1039

Merged
pblazej merged 1 commit into
mainfrom
blaze/snapshot-build-fix
Jun 10, 2026
Merged

Fix Swift snapshot build: don't reference withAUAudioUnit#1039
pblazej merged 1 commit into
mainfrom
blaze/snapshot-build-fix

Conversation

@pblazej

@pblazej pblazej commented Jun 10, 2026

Copy link
Copy Markdown
Contributor

Summary

Follow-up to #1038. The nightly Swift Snapshot Build (.github/workflows/swift-snapshot.yaml) fails on main after #1038:

Sources/LiveKit/Extensions/AVAudioNode.swift:34:24: error: cannot find 'withAUAudioUnit' in scope

Root cause

That workflow runs swift build with the main-snapshot compiler (so #if compiler(>=6.4) is true) but against the runner's current stable SDK (macOS 26 — latest Xcode, since 27 is still beta). withAUAudioUnit only exists in the macOS 27 SDK, so the compiler(>=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 withAUAudioUnit and reach auAudioUnit — which exists on every SDK (only its Swift availability annotation differs) — under if #available(macOS 13.0), falling back to LKObjCHelpers below 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 native with the Xcode 27 compiler + macОS 26 SDK (reproduces the snapshot combo): Build complete ✅ (was: cannot find 'withAUAudioUnit').
  • Xcode 27 (macOS/iOS) and Xcode 26.5 (macOS) builds: ✅
  • swiftformat clean.

No user-facing behavior change (the auAudioUnit access is functionally identical), so no changeset.

🤖 Generated with Claude Code

…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>
@github-actions

Copy link
Copy Markdown

⚠️ This PR does not contain any files in the .changes directory.

@pblazej pblazej merged commit bc05a32 into main Jun 10, 2026
22 of 23 checks passed
@pblazej pblazej deleted the blaze/snapshot-build-fix branch June 10, 2026 11:38
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.

2 participants