From e02e8be652f58686a8c9136267ac4b37696a8f62 Mon Sep 17 00:00:00 2001 From: deadcafe Date: Wed, 7 Oct 2026 04:49:28 +0530 Subject: [PATCH] Fix nightly-main build: guard versioned canImport(CryptoKit) checks The Swift 6.5 nightly compiler warns when a versioned `#if canImport(Module, _version:)` names a module it cannot find (CanImportMissingModule). CI builds with -warnings-as-errors, so the four CryptoKit version checks in CryptoWrappers.swift failed the Linux nightly-main jobs, where CryptoKit does not exist. Follow the documented remedy: check that the module can be imported at all before checking its version. The directive still evaluates to false on Linux, so the SwiftCrypto fallback path is unchanged, and older compilers accept the combined condition. --- Sources/SwiftNetwork/Utilities/CryptoWrappers.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Sources/SwiftNetwork/Utilities/CryptoWrappers.swift b/Sources/SwiftNetwork/Utilities/CryptoWrappers.swift index 9d1fb623..43ead76d 100644 --- a/Sources/SwiftNetwork/Utilities/CryptoWrappers.swift +++ b/Sources/SwiftNetwork/Utilities/CryptoWrappers.swift @@ -43,7 +43,7 @@ extension AES.GCM { #if DISABLE_SHIM_CRYPTO_SPAN_APIS try seal(inPlace: &message, using: key, nonce: nonce, authenticating: authenticatedData, tag: &tag) #else - #if canImport(CryptoKit, _version: 383.2.1) + #if canImport(CryptoKit) && canImport(CryptoKit, _version: 383.2.1) if #available(macOS 27, iOS 27, watchOS 27, tvOS 27, visionOS 27, *) { try seal(inPlace: &message, using: key, nonce: nonce, authenticating: authenticatedData, tag: &tag) return @@ -69,7 +69,7 @@ extension AES.GCM { #if DISABLE_SHIM_CRYPTO_SPAN_APIS try open(inPlace: &message, using: key, nonce: nonce, authenticating: authenticatedData, tag: tag) #else - #if canImport(CryptoKit, _version: 383.2.1) + #if canImport(CryptoKit) && canImport(CryptoKit, _version: 383.2.1) if #available(macOS 27, iOS 27, watchOS 27, tvOS 27, visionOS 27, *) { try open(inPlace: &message, using: key, nonce: nonce, authenticating: authenticatedData, tag: tag) return @@ -93,7 +93,7 @@ extension ChaChaPoly { #if DISABLE_SHIM_CRYPTO_SPAN_APIS try seal(inPlace: &message, using: key, nonce: nonce, authenticating: authenticatedData, tag: &tag) #else - #if canImport(CryptoKit, _version: 383.2.1) + #if canImport(CryptoKit) && canImport(CryptoKit, _version: 383.2.1) if #available(macOS 27, iOS 27, watchOS 27, tvOS 27, visionOS 27, *) { try seal(inPlace: &message, using: key, nonce: nonce, authenticating: authenticatedData, tag: &tag) return @@ -119,7 +119,7 @@ extension ChaChaPoly { #if DISABLE_SHIM_CRYPTO_SPAN_APIS try open(inPlace: &message, using: key, nonce: nonce, authenticating: authenticatedData, tag: tag) #else - #if canImport(CryptoKit, _version: 383.2.1) + #if canImport(CryptoKit) && canImport(CryptoKit, _version: 383.2.1) if #available(macOS 27, iOS 27, watchOS 27, tvOS 27, visionOS 27, *) { try open(inPlace: &message, using: key, nonce: nonce, authenticating: authenticatedData, tag: tag) return