From 51827fb5b5f1938d416b48a2a999f0a7288f47be Mon Sep 17 00:00:00 2001 From: James Power Date: Mon, 29 Jun 2026 05:57:08 -0400 Subject: [PATCH] Fix Windows build: gate CZlib to platforms with system zlib. --- Package.swift | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/Package.swift b/Package.swift index f00ec2e..efa2c6f 100644 --- a/Package.swift +++ b/Package.swift @@ -8,8 +8,12 @@ var products: [Product] = [ ] var targets: [Target] = [ - // Thin C wrapper exposing system zlib to Swift. - // zlib is present on macOS (SDK) and Linux (Swift toolchain dependency). + // Thin C wrapper exposing system zlib to Swift. The dependency below is gated to the + // platforms we build for and know ship zlib (macOS SDK, Linux toolchain). A platform + // condition is evaluated against the build *destination*, so this stays correct under + // cross-compilation — unlike a manifest `#if os(...)`, which keys off the host. On + // any other destination (Windows, wasm) CZlib drops out of the graph and the + // `#if canImport(CZlib)`-guarded MCCP compression compiles out. .target( name: "CZlib", path: "Sources/CZlib", @@ -20,7 +24,7 @@ var targets: [Target] = [ .target( name: "MTHCore", dependencies: [ - "CZlib", + .target(name: "CZlib", condition: .when(platforms: [.macOS, .linux])), ], path: "Sources/SwiftMTHCore" ),