Skip to content

Fix Linux build: declare swift-nio as an explicit dependency for NIOFoundationCompat#56

Merged
jamesrochabrun merged 1 commit into
jamesrochabrun:mainfrom
gestrich:main
Apr 18, 2026
Merged

Fix Linux build: declare swift-nio as an explicit dependency for NIOFoundationCompat#56
jamesrochabrun merged 1 commit into
jamesrochabrun:mainfrom
gestrich:main

Conversation

@gestrich

Copy link
Copy Markdown
Contributor

Problem

Building a package that depends on SwiftAnthropic on Linux currently fails with:

AsyncHTTPClientAdapter.swift:12:8: error: no such module 'NIOFoundationCompat'

AsyncHTTPClientAdapter.swift imports NIOFoundationCompat to use Data(buffer:) for converting the ByteBuffer returned by async-http-client into Foundation's Data. However, swift-nio — the package that provides NIOFoundationCompat — is not declared as an explicit dependency in Package.swift.

async-http-client depends on swift-nio internally, but does not re-export NIOFoundationCompat as a product. Swift Package Manager does not guarantee that modules from transitive dependencies are importable, and in practice this build fails on Linux regardless of Swift version or runner environment.

Fix

Add swift-nio as an explicit package dependency and add NIOFoundationCompat as a Linux-conditional target dependency — matching the pattern already used for AsyncHTTPClient.

The from: "2.81.0" lower bound matches the minimum swift-nio version already required by async-http-client 1.25.2+, so this introduces no new version constraints in practice.

Verification

Tested against a minimal Swift 6.2 CLI package depending on SwiftAnthropic, built on ubuntu-latest using the official swift:latest Docker container. The build fails on main and passes with this fix applied.

AsyncHTTPClientAdapter.swift imports NIOFoundationCompat (used for
Data(buffer:) ByteBuffer conversion), but swift-nio was not declared
as an explicit dependency in Package.swift. On Linux, NIOFoundationCompat
is not re-exported through async-http-client, so the module cannot be found.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gestrich gestrich marked this pull request as ready for review April 11, 2026 10:01
@jamesrochabrun jamesrochabrun merged commit 783bdce into jamesrochabrun:main Apr 18, 2026
2 checks passed
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