Describe the feature
The AWS SDK for Swift unconditionally imports Foundation across many generated and hand-written files (e.g. AWSBedrockRuntime/BedrockRuntimeClient.swift, AWSBedrockRuntime/Models.swift, and similar files in every service module). On Linux, this transitively links libFoundation.so (and libFoundationInternationalization.so / lib_FoundationICU.so) into any executable that consumes the SDK — even if the consuming application has carefully guarded its own Foundation usage with #if canImport(FoundationEssentials).
Please consider adopting the FoundationEssentials opt-in pattern across the SDK so that downstream packages can produce binaries free of the full Foundation/ICU runtime on Linux.
The recommended pattern is:
#if canImport(FoundationEssentials)
import FoundationEssentials
#else
import Foundation
#endif
…applied to every generated and hand-written source file that does not depend on the Foundation-only types (e.g. URLSession, XMLParser, NSRegularExpression, NumberFormatter, etc.).
Use Case
We maintain swift-bedrock-library (build-on-aws/swift-bedrock-library), a high-level Swift client built on top of aws-sdk-swift. The library sources guard their Foundation imports with the FoundationEssentials pattern, but our CI cannot enforce a Foundation-free build because the AWS SDK pulls in libFoundation.so transitively.
Foundation-free builds matter for several scenarios:
- AWS Lambda / serverless: smaller deployment packages, faster cold starts, fewer ICU-related runtime surprises.
- Embedded / size-constrained environments: where every megabyte of
libFoundation.so (and its ~30 MB ICU dependency) counts.
- Static linking: enables fully static binaries with
--static-swift-stdlib without dragging in ICU symbols that conflict with system ICU.
The Swift Server ecosystem (e.g. SwiftNIO, swift-log, swift-collections, swift-crypto) has been migrating to FoundationEssentials for these reasons.
Proposed Solution
- Audit per file which Foundation symbols are actually used. The vast majority of generated SDK code uses only
Data, URL, Date, JSONEncoder/Decoder, String/Int extensions — all of which are available in FoundationEssentials.
- Update the Smithy code generator to emit the
#if canImport(FoundationEssentials) guard at the top of every generated file.
- Refactor hand-written files (in
AWSClientRuntime, AWSSDKIdentity, AWSSDKChecksums, etc.) the same way.
- Identify the modules that genuinely need full Foundation (likely a subset that uses
URLSession, FileManager, XMLParser) and isolate those behind separate targets so consumers who don't need them can avoid the dependency.
- Add a CI job that links a representative example and runs
ldd / otool -L to assert the absence of libFoundation.so / libFoundationInternationalization.so / lib_FoundationICU.so. (Happy to share the exact CI script once we get one working downstream.)
Other Information
Acknowledgements
SDK version used
aws-sdk-swift 1.7.x (latest as of November 2026)
Operating System and version
Linux (Ubuntu 22.04, Amazon Linux 2023) — symptom is most visible there. macOS already statically links Foundation into the runtime.
Describe the feature
The AWS SDK for Swift unconditionally imports
Foundationacross many generated and hand-written files (e.g.AWSBedrockRuntime/BedrockRuntimeClient.swift,AWSBedrockRuntime/Models.swift, and similar files in every service module). On Linux, this transitively linkslibFoundation.so(andlibFoundationInternationalization.so/lib_FoundationICU.so) into any executable that consumes the SDK — even if the consuming application has carefully guarded its own Foundation usage with#if canImport(FoundationEssentials).Please consider adopting the
FoundationEssentialsopt-in pattern across the SDK so that downstream packages can produce binaries free of the full Foundation/ICU runtime on Linux.The recommended pattern is:
…applied to every generated and hand-written source file that does not depend on the Foundation-only types (e.g.
URLSession,XMLParser,NSRegularExpression,NumberFormatter, etc.).Use Case
We maintain
swift-bedrock-library(build-on-aws/swift-bedrock-library), a high-level Swift client built on top ofaws-sdk-swift. The library sources guard their Foundation imports with theFoundationEssentialspattern, but our CI cannot enforce a Foundation-free build because the AWS SDK pulls inlibFoundation.sotransitively.Foundation-free builds matter for several scenarios:
libFoundation.so(and its ~30 MB ICU dependency) counts.--static-swift-stdlibwithout dragging in ICU symbols that conflict with system ICU.The Swift Server ecosystem (e.g. SwiftNIO, swift-log, swift-collections, swift-crypto) has been migrating to
FoundationEssentialsfor these reasons.Proposed Solution
Data,URL,Date,JSONEncoder/Decoder,String/Intextensions — all of which are available inFoundationEssentials.#if canImport(FoundationEssentials)guard at the top of every generated file.AWSClientRuntime,AWSSDKIdentity,AWSSDKChecksums, etc.) the same way.URLSession,FileManager,XMLParser) and isolate those behind separate targets so consumers who don't need them can avoid the dependency.ldd/otool -Lto assert the absence oflibFoundation.so/libFoundationInternationalization.so/lib_FoundationICU.so. (Happy to share the exact CI script once we get one working downstream.)Other Information
Acknowledgements
SDK version used
aws-sdk-swift1.7.x (latest as of November 2026)Operating System and version
Linux (Ubuntu 22.04, Amazon Linux 2023) — symptom is most visible there. macOS already statically links Foundation into the runtime.