Skip to content

Fix: Add explicit swift-service-context dependency for Xcode 26 transitive dylib bug#891

Merged
fabianfett merged 2 commits intoswift-server:mainfrom
intrusive-memory:xcode26-transitive-fix
Feb 25, 2026
Merged

Fix: Add explicit swift-service-context dependency for Xcode 26 transitive dylib bug#891
fabianfett merged 2 commits intoswift-server:mainfrom
intrusive-memory:xcode26-transitive-fix

Conversation

@stovak
Copy link
Contributor

@stovak stovak commented Feb 24, 2026

Problem

Xcode 26 introduced a regression in Swift Package Manager builds where packages built as dynamic frameworks don't properly propagate transitive framework dependencies during the link phase.

Symptoms

When AsyncHTTPClient is used as a transitive dependency (i.e., Package A → Package B → AsyncHTTPClient), the build fails with:

Undefined symbols for architecture arm64:
  "_$s20ServiceContextModule0aB3KeyPTl", referenced from:
      _$s17AsyncHTTPClient0bC0V7executeyyAA15HTTPExecutorJobCYaKF in AsyncHTTPClient.o

Root Cause

  • Xcode 26 builds all "automatic" SPM products as dynamic frameworks (*.framework)
  • AsyncHTTPClient uses symbols from ServiceContextModule (via inlined code from Tracing)
  • However, AsyncHTTPClient's Package.swift doesn't declare swift-service-context as a direct dependency
  • It only declares swift-distributed-tracing, which itself depends on swift-service-context
  • Xcode 26 correctly links ServiceContextModule.framework into Tracing.framework
  • BUT Xcode 26 fails to propagate this transitive dependency when linking AsyncHTTPClient.framework
  • Result: AsyncHTTPClient.o references ServiceContextModule symbols but the framework doesn't link against it

Solution

Add explicit package-level and target-level dependencies for swift-service-context to ensure Xcode 26 can link the framework correctly.

Changes

  • Added .package(url: "https://github.com/apple/swift-service-context.git", from: "1.1.0") to package dependencies
  • Added .product(name: "ServiceContextModule", package: "swift-service-context") to AsyncHTTPClient target dependencies
  • Added same to AsyncHTTPClientTests target for test builds

Impact

  • No functional changes - ServiceContextModule was already available transitively through Tracing
  • Fixes builds for projects using AsyncHTTPClient as a transitive dependency under Xcode 26
  • No impact on Xcode 25 or earlier (explicit dependency is redundant but harmless)
  • No impact on Linux/Swift CLI builds (they don't have the transitive dylib bug)

Testing

Verified that this fixes builds for projects with dependency chains like:

App → SwiftBruja → VoxAlta → AsyncHTTPClient

Previously failed with undefined symbols, now builds and links correctly.


Related Issue: This is a workaround for an Xcode 26 regression. Ideally Apple would fix the SPM dylib linking behavior, but adding explicit dependencies is a reasonable defensive practice regardless.

…itive dylib bug

Xcode 26 builds all "automatic" SPM package products as dynamic frameworks
but does not propagate transitive framework dependencies. This causes
undefined symbol errors for ServiceContextModule when AsyncHTTPClient is
used as a transitive dependency. Adding the explicit dependency resolves this.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@fabianfett fabianfett enabled auto-merge (squash) February 25, 2026 12:14
@fabianfett fabianfett added the 🔨 semver/patch No public API change. label Feb 25, 2026
@fabianfett fabianfett merged commit 2fc4652 into swift-server:main Feb 25, 2026
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🔨 semver/patch No public API change.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants