diff --git a/Sources/STFilePath/Compression/STComparator.swift b/Sources/STFilePath/Compression/STComparator.swift index 0149f8e..9810807 100644 --- a/Sources/STFilePath/Compression/STComparator.swift +++ b/Sources/STFilePath/Compression/STComparator.swift @@ -1,3 +1,4 @@ +#if canImport(Compression) import Foundation import Compression @@ -109,3 +110,4 @@ private extension STComparator { } } +#endif diff --git a/Sources/STFilePath/DownloadableFile/DownloadableFile.swift b/Sources/STFilePath/DownloadableFile/DownloadableFile.swift index 03e55d2..b988d57 100644 --- a/Sources/STFilePath/DownloadableFile/DownloadableFile.swift +++ b/Sources/STFilePath/DownloadableFile/DownloadableFile.swift @@ -55,6 +55,7 @@ public extension DownloadableFile { DFFileMap(file: self, fetch: fetch, save: save) } +#if canImport(Compression) /// [en] Compresses and decompresses the file data using the specified algorithm. /// [zh] 使用指定的算法压缩和解压缩文件数据。 /// - Parameter algorithm: The compression algorithm to use. @@ -66,6 +67,7 @@ public extension DownloadableFile { try STComparator.compress(model, algorithm: algorithm) } } +#endif /// [en] Maps the file data to a `Codable` type. /// [zh] 将文件数据映射到 `Codable` 类型。 diff --git a/Tests/STFilePathTests/DownloadableFileTests.swift b/Tests/STFilePathTests/DownloadableFileTests.swift index 27de8df..3800fcb 100644 --- a/Tests/STFilePathTests/DownloadableFileTests.swift +++ b/Tests/STFilePathTests/DownloadableFileTests.swift @@ -35,6 +35,7 @@ struct DownloadableFileTests { #expect(fetchedModel2 != model1) } +#if canImport(Compression) @Test("Compression Transformation") func testCompression() async throws { let testFolder = try createTestFolder() @@ -56,4 +57,5 @@ struct DownloadableFileTests { let decompressedData = try await downloadableFile.fetch() #expect(decompressedData == originalData) } +#endif } diff --git a/Tests/STFilePathTests/Test.swift b/Tests/STFilePathTests/Test.swift index e5914aa..9ce8b53 100644 --- a/Tests/STFilePathTests/Test.swift +++ b/Tests/STFilePathTests/Test.swift @@ -9,6 +9,7 @@ import Foundation import STFilePath import Testing +#if canImport(Compression) struct CompressionTest { @Test func testCompressionRoundTrip() throws { @@ -23,3 +24,4 @@ struct CompressionTest { } } +#endif