From 539b73d9d028f21720618df1e19e06313a1c484b Mon Sep 17 00:00:00 2001 From: agnosticdev Date: Fri, 3 Jul 2026 12:41:01 -0700 Subject: [PATCH 1/8] agnosticdev/CryptoTrait: Test Crypto trait --- Package.swift | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/Package.swift b/Package.swift index 85fc553..e3b25e3 100644 --- a/Package.swift +++ b/Package.swift @@ -45,11 +45,7 @@ let settings: [SwiftSetting] = [ .define("EXPORT_SWIFTTLS"), .define("IMPORT_CRYPTO"), .define("SWIFTTLS_CERTIFICATE_VERIFICATION"), - // To support back to macOS 26, provide a shim on top of crypto APIs - // that allows passing spans. This is a less performant path, so for - // performance-sensitive cases, remove this define and require at least - // macOS 27. - .define("SHIM_CRYPTO_SPAN_APIS", .when(platforms: allApplePlatforms)), + //.define("SHIM_CRYPTO_SPAN_APIS", .when(platforms: allApplePlatforms)), .unsafeFlags(["-Xfrontend", "-experimental-spi-only-imports"]), .enableExperimentalFeature("Lifetimes"), .enableExperimentalFeature("AnyAppleOSAvailability"), @@ -90,7 +86,15 @@ let package = Package( name: "SignpostOutput", description: "Enables `OSSignposter` output from the QUIC implementation." ), - .default(enabledTraits: []), + // To support back to macOS 26, provide a shim on top of crypto APIs + // that allows passing spans. This is a less performant path, so for + // performance-sensitive cases, remove this define and require at least + // macOS 27. + .trait( + name: "SHIM_CRYPTO_SPAN_APIS", + description: "To support back to macOS 26, provide a shim on top of crypto APIs that allows passing spans" + ), + .default(enabledTraits: ["SHIM_CRYPTO_SPAN_APIS"]), ], dependencies: [ .package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"), From 200cc4ed61c598967143f6c723ec6db56011cb87 Mon Sep 17 00:00:00 2001 From: agnosticdev Date: Mon, 6 Jul 2026 07:24:24 -0700 Subject: [PATCH 2/8] agnosticdev/CryptoTrait: Moved crypto trait functionality around --- .github/workflows/pull_request.yml | 10 +++++----- Package.swift | 3 +-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 42d9fe3..42b2248 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -17,13 +17,13 @@ jobs: bash -c ' rc=0; echo "=== xcodebuild macOS ==="; - /usr/bin/xcodebuild -quiet -scheme swift-network-evolution-Package -destination "generic/platform=macos,variant=macos" build && macos=PASSED || { rc=1; macos=FAILED; }; + /usr/bin/xcodebuild -DSHIM_CRYPTO_SPAN_APIS -quiet -scheme swift-network-evolution-Package -destination "generic/platform=macos,variant=macos" build && macos=PASSED || { rc=1; macos=FAILED; }; echo "=== macOS build: $macos ==="; echo "=== xcodebuild Mac Catalyst ==="; - /usr/bin/xcodebuild -quiet -scheme swift-network-evolution-Package -destination "generic/platform=macos,variant=Mac Catalyst" build && catalyst=PASSED || { rc=1; catalyst=FAILED; }; + /usr/bin/xcodebuild -DSHIM_CRYPTO_SPAN_APIS -quiet -scheme swift-network-evolution-Package -destination "generic/platform=macos,variant=Mac Catalyst" build && catalyst=PASSED || { rc=1; catalyst=FAILED; }; echo "=== Mac Catalyst build: $catalyst ==="; echo "=== xcodebuild iOS ==="; - /usr/bin/xcodebuild -quiet -scheme swift-network-evolution-Package -destination "generic/platform=ios" build && ios=PASSED || { rc=1; ios=FAILED; }; + /usr/bin/xcodebuild -DSHIM_CRYPTO_SPAN_APIS -quiet -scheme swift-network-evolution-Package -destination "generic/platform=ios" build && ios=PASSED || { rc=1; ios=FAILED; }; echo "=== iOS build: $ios ==="; echo "=== xcodebuild watchOS ==="; /usr/bin/xcodebuild -quiet -scheme swift-network-evolution-Package -destination "generic/platform=watchos" build && watchos=PASSED || { rc=1; watchos=FAILED; }; @@ -32,10 +32,10 @@ jobs: /usr/bin/xcodebuild -quiet -scheme swift-network-evolution-Package -destination "generic/platform=tvos" build && tvos=PASSED || { rc=1; tvos=FAILED; }; echo "=== tvOS build: $tvos ==="; echo "=== xcodebuild visionOS ==="; - /usr/bin/xcodebuild -quiet -scheme swift-network-evolution-Package -destination "generic/platform=visionos" build && visionos=PASSED || { rc=1; visionos=FAILED; }; + /usr/bin/xcodebuild - -quiet -scheme swift-network-evolution-Package -destination "generic/platform=visionos" build && visionos=PASSED || { rc=1; visionos=FAILED; }; echo "=== visionOS build: $visionos ==="; echo "=== xcrun swift test ==="; - xcrun swift test --quiet "$@" && tests=PASSED || { rc=1; tests=FAILED; }; + xcrun swift test --traits SHIM_CRYPTO_SPAN_APIS --quiet "$@" && tests=PASSED || { rc=1; tests=FAILED; }; echo "=== swift test: $tests ==="; echo "=== Summary ==="; printf "%-20s %s\n" "macOS build:" "$macos"; diff --git a/Package.swift b/Package.swift index e3b25e3..f47cc86 100644 --- a/Package.swift +++ b/Package.swift @@ -45,7 +45,6 @@ let settings: [SwiftSetting] = [ .define("EXPORT_SWIFTTLS"), .define("IMPORT_CRYPTO"), .define("SWIFTTLS_CERTIFICATE_VERIFICATION"), - //.define("SHIM_CRYPTO_SPAN_APIS", .when(platforms: allApplePlatforms)), .unsafeFlags(["-Xfrontend", "-experimental-spi-only-imports"]), .enableExperimentalFeature("Lifetimes"), .enableExperimentalFeature("AnyAppleOSAvailability"), @@ -94,7 +93,7 @@ let package = Package( name: "SHIM_CRYPTO_SPAN_APIS", description: "To support back to macOS 26, provide a shim on top of crypto APIs that allows passing spans" ), - .default(enabledTraits: ["SHIM_CRYPTO_SPAN_APIS"]), + .default(enabledTraits: []), ], dependencies: [ .package(url: "https://github.com/apple/swift-log.git", from: "1.0.0"), From 548086b7442d234c8e442d44090be7b593e00a6f Mon Sep 17 00:00:00 2001 From: agnosticdev Date: Mon, 6 Jul 2026 08:55:47 -0700 Subject: [PATCH 3/8] Test with not trait --- Package.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Package.swift b/Package.swift index f47cc86..6dda9fd 100644 --- a/Package.swift +++ b/Package.swift @@ -89,10 +89,10 @@ let package = Package( // that allows passing spans. This is a less performant path, so for // performance-sensitive cases, remove this define and require at least // macOS 27. - .trait( - name: "SHIM_CRYPTO_SPAN_APIS", - description: "To support back to macOS 26, provide a shim on top of crypto APIs that allows passing spans" - ), +// .trait( +// name: "SHIM_CRYPTO_SPAN_APIS", +// description: "To support back to macOS 26, provide a shim on top of crypto APIs that allows passing spans" +// ), .default(enabledTraits: []), ], dependencies: [ From d56baee00da30b97bafa9c91ac337d3b4ed80d38 Mon Sep 17 00:00:00 2001 From: agnosticdev Date: Mon, 6 Jul 2026 09:50:51 -0700 Subject: [PATCH 4/8] Adding back the trait --- Package.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Package.swift b/Package.swift index 6dda9fd..e95a4d5 100644 --- a/Package.swift +++ b/Package.swift @@ -89,10 +89,10 @@ let package = Package( // that allows passing spans. This is a less performant path, so for // performance-sensitive cases, remove this define and require at least // macOS 27. -// .trait( -// name: "SHIM_CRYPTO_SPAN_APIS", -// description: "To support back to macOS 26, provide a shim on top of crypto APIs that allows passing spans" -// ), + .trait( + name: "SHIM_CRYPTO_SPAN_APIS", + description: "To support back to macOS 26, provide a shim on top of crypto APIs that allows passing spans" + ), .default(enabledTraits: []), ], dependencies: [ From e2e66e556775ee54c68500eeb9be03244f3207df Mon Sep 17 00:00:00 2001 From: agnosticdev Date: Mon, 6 Jul 2026 10:45:28 -0700 Subject: [PATCH 5/8] Switch polarity of trait --- .github/workflows/pull_request.yml | 8 ++++---- Sources/SwiftNetwork/Utilities/CryptoWrappers.swift | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index 42b2248..aceca97 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -17,13 +17,13 @@ jobs: bash -c ' rc=0; echo "=== xcodebuild macOS ==="; - /usr/bin/xcodebuild -DSHIM_CRYPTO_SPAN_APIS -quiet -scheme swift-network-evolution-Package -destination "generic/platform=macos,variant=macos" build && macos=PASSED || { rc=1; macos=FAILED; }; + /usr/bin/xcodebuild -quiet -scheme swift-network-evolution-Package -destination "generic/platform=macos,variant=macos" build && macos=PASSED || { rc=1; macos=FAILED; }; echo "=== macOS build: $macos ==="; echo "=== xcodebuild Mac Catalyst ==="; - /usr/bin/xcodebuild -DSHIM_CRYPTO_SPAN_APIS -quiet -scheme swift-network-evolution-Package -destination "generic/platform=macos,variant=Mac Catalyst" build && catalyst=PASSED || { rc=1; catalyst=FAILED; }; + /usr/bin/xcodebuild -quiet -scheme swift-network-evolution-Package -destination "generic/platform=macos,variant=Mac Catalyst" build && catalyst=PASSED || { rc=1; catalyst=FAILED; }; echo "=== Mac Catalyst build: $catalyst ==="; echo "=== xcodebuild iOS ==="; - /usr/bin/xcodebuild -DSHIM_CRYPTO_SPAN_APIS -quiet -scheme swift-network-evolution-Package -destination "generic/platform=ios" build && ios=PASSED || { rc=1; ios=FAILED; }; + /usr/bin/xcodebuild -quiet -scheme swift-network-evolution-Package -destination "generic/platform=ios" build && ios=PASSED || { rc=1; ios=FAILED; }; echo "=== iOS build: $ios ==="; echo "=== xcodebuild watchOS ==="; /usr/bin/xcodebuild -quiet -scheme swift-network-evolution-Package -destination "generic/platform=watchos" build && watchos=PASSED || { rc=1; watchos=FAILED; }; @@ -35,7 +35,7 @@ jobs: /usr/bin/xcodebuild - -quiet -scheme swift-network-evolution-Package -destination "generic/platform=visionos" build && visionos=PASSED || { rc=1; visionos=FAILED; }; echo "=== visionOS build: $visionos ==="; echo "=== xcrun swift test ==="; - xcrun swift test --traits SHIM_CRYPTO_SPAN_APIS --quiet "$@" && tests=PASSED || { rc=1; tests=FAILED; }; + xcrun swift test --quiet "$@" && tests=PASSED || { rc=1; tests=FAILED; }; echo "=== swift test: $tests ==="; echo "=== Summary ==="; printf "%-20s %s\n" "macOS build:" "$macos"; diff --git a/Sources/SwiftNetwork/Utilities/CryptoWrappers.swift b/Sources/SwiftNetwork/Utilities/CryptoWrappers.swift index 05ae29c..c3fcfe7 100644 --- a/Sources/SwiftNetwork/Utilities/CryptoWrappers.swift +++ b/Sources/SwiftNetwork/Utilities/CryptoWrappers.swift @@ -15,7 +15,7 @@ // Wrappers over older Crypto functions when span-based APIs are not available. // This path exists for compatibility, but is significantly less efficient. -#if SHIM_CRYPTO_SPAN_APIS +#if !SHIM_CRYPTO_SPAN_APIS #if canImport(Foundation) import Foundation #elseif canImport(SwiftSystem) From 18d2339680bc5d571af50d0aa6f41d17fd57f3c9 Mon Sep 17 00:00:00 2001 From: agnosticdev Date: Mon, 6 Jul 2026 11:04:17 -0700 Subject: [PATCH 6/8] Renamed shim name --- Package.swift | 9 ++++----- Sources/SwiftNetwork/Utilities/CryptoWrappers.swift | 2 +- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/Package.swift b/Package.swift index e95a4d5..8aa35b6 100644 --- a/Package.swift +++ b/Package.swift @@ -86,12 +86,11 @@ let package = Package( description: "Enables `OSSignposter` output from the QUIC implementation." ), // To support back to macOS 26, provide a shim on top of crypto APIs - // that allows passing spans. This is a less performant path, so for - // performance-sensitive cases, remove this define and require at least - // macOS 27. + // that allows passing spans is provided. This is a less performant path, so for + // performance-sensitive cases, pass in this trait to disable this shim. .trait( - name: "SHIM_CRYPTO_SPAN_APIS", - description: "To support back to macOS 26, provide a shim on top of crypto APIs that allows passing spans" + name: "DISABLE_SHIM_CRYPTO_SPAN_APIS", + description: "Disable backwards compatible crypto shim for performance sensitive cases" ), .default(enabledTraits: []), ], diff --git a/Sources/SwiftNetwork/Utilities/CryptoWrappers.swift b/Sources/SwiftNetwork/Utilities/CryptoWrappers.swift index c3fcfe7..a357870 100644 --- a/Sources/SwiftNetwork/Utilities/CryptoWrappers.swift +++ b/Sources/SwiftNetwork/Utilities/CryptoWrappers.swift @@ -15,7 +15,7 @@ // Wrappers over older Crypto functions when span-based APIs are not available. // This path exists for compatibility, but is significantly less efficient. -#if !SHIM_CRYPTO_SPAN_APIS +#if !DISABLE_SHIM_CRYPTO_SPAN_APIS #if canImport(Foundation) import Foundation #elseif canImport(SwiftSystem) From ea7588d97a54dd6d09cf43d23a5bfb950d50dcc1 Mon Sep 17 00:00:00 2001 From: agnosticdev Date: Mon, 6 Jul 2026 11:05:52 -0700 Subject: [PATCH 7/8] Formatting --- Package.swift | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Package.swift b/Package.swift index 8aa35b6..2b0c50e 100644 --- a/Package.swift +++ b/Package.swift @@ -87,11 +87,11 @@ let package = Package( ), // To support back to macOS 26, provide a shim on top of crypto APIs // that allows passing spans is provided. This is a less performant path, so for - // performance-sensitive cases, pass in this trait to disable this shim. - .trait( - name: "DISABLE_SHIM_CRYPTO_SPAN_APIS", - description: "Disable backwards compatible crypto shim for performance sensitive cases" - ), + // performance-sensitive cases, pass in this trait to disable this shim. + .trait( + name: "DISABLE_SHIM_CRYPTO_SPAN_APIS", + description: "Disable backwards compatible crypto shim for performance sensitive cases" + ), .default(enabledTraits: []), ], dependencies: [ From f8165ebfcd2eec04c456ced2ca6b118791a0665b Mon Sep 17 00:00:00 2001 From: agnosticdev Date: Mon, 6 Jul 2026 11:16:39 -0700 Subject: [PATCH 8/8] Fix formatting --- .github/workflows/pull_request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pull_request.yml b/.github/workflows/pull_request.yml index aceca97..42d9fe3 100644 --- a/.github/workflows/pull_request.yml +++ b/.github/workflows/pull_request.yml @@ -32,7 +32,7 @@ jobs: /usr/bin/xcodebuild -quiet -scheme swift-network-evolution-Package -destination "generic/platform=tvos" build && tvos=PASSED || { rc=1; tvos=FAILED; }; echo "=== tvOS build: $tvos ==="; echo "=== xcodebuild visionOS ==="; - /usr/bin/xcodebuild - -quiet -scheme swift-network-evolution-Package -destination "generic/platform=visionos" build && visionos=PASSED || { rc=1; visionos=FAILED; }; + /usr/bin/xcodebuild -quiet -scheme swift-network-evolution-Package -destination "generic/platform=visionos" build && visionos=PASSED || { rc=1; visionos=FAILED; }; echo "=== visionOS build: $visionos ==="; echo "=== xcrun swift test ==="; xcrun swift test --quiet "$@" && tests=PASSED || { rc=1; tests=FAILED; };