Merged
Conversation
On Linux, Foundation networking types (URLSession, URLRequest, URLCache, etc.) live in a separate FoundationNetworking module. Add conditional imports to all source and test files that use these types. Also add a Linux CI job using the swift:6.2 container on ubuntu-latest, and remove a redundant @available annotation from MiddlewareTests that would be meaningless on Linux. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Use public import FoundationNetworking in files with public APIs that expose URLSession, URLCache, or URLRequest (URLSessionTransport, URLSessionClient, CacheMiddleware). Plain import for ClientError since URLError resolves through Foundation on Linux. - Handle URLError.Code(rawValue:) being failable on Linux but non-failable on Apple platforms with #if canImport conditional. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
URLRequest.CachePolicy enum cases in swift-corelibs-foundation are not marked @usableFromInline, so @inlinable code cannot reference them. Remove @inlinable from urlRequestCachePolicy and use conditional public imports so the return type resolves correctly on both platforms. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Linux's swift-corelibs-foundation requires the diskPath parameter for URLCache init (no default value), while Apple's version defaults directoryURL to nil. Use #if canImport(FoundationNetworking) to select the correct initializer on each platform. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
URL.appending(queryItems:) behaves differently on Linux's swift-corelibs-foundation, causing query parameters to be lost in URL reconstruction. Replace with URLComponents-based construction which handles query items reliably on both platforms. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
URLCache in swift-corelibs-foundation does not differentiate cache entries by query parameters, causing these tests to fail. The tests verify Foundation URLCache behavior rather than Simplicity logic, so skip them on Linux with #if !canImport(FoundationNetworking). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
URLCache in swift-corelibs-foundation does not differentiate cache entries by URL query parameters. Work around this by creating synthetic cache key URLs that encode the full URL (including query string) into the path component, ensuring unique cache entries on all platforms. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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
swift:6.2container onubuntu-latest) to the existing test matrix#if canImport(FoundationNetworking)conditional imports across source and test files so the package compiles on Linux, whereURLSession,URLRequest,URLCache, etc. live inFoundationNetworkingrather thanFoundationURLCachedoes not differentiate cache entries by URL query parameters, using synthetic cache-key URLs that encode the full URL into the path componentNotable platform differences handled
public importvsimportforFoundationNetworkingdepending on whether the file exposes networking types in its public API (MemberImportVisibility)@inlinableremoved fromCachePolicy.urlRequestCachePolicybecause swift-corelibs-foundation'sURLRequest.CachePolicycases are not@usableFromInlineURLError.Code(rawValue:)is failable on Linux, non-failable on AppleURLCache(memoryCapacity:diskCapacity:)requires adiskPath:parameter on LinuxURL.appending(queryItems:)replaced withURLComponents-based construction for cross-platform reliabilityTest plan
swift buildandswift test🤖 Generated with Claude Code