From e504d6be035e4c3bf45c55e06eed39e7c4bc0f82 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?C=C3=A9sar?= Date: Wed, 9 Aug 2023 14:51:24 +0200 Subject: [PATCH 1/9] Add xrOS as OS conditional check --- Package@swift-4.0.swift | 2 +- Sources/ZIPFoundation/Archive+MemoryFile.swift | 4 ++-- Sources/ZIPFoundation/Archive+Writing.swift | 2 +- Sources/ZIPFoundation/Data+Compression.swift | 8 ++++---- Sources/ZIPFoundation/Date+ZIP.swift | 4 ++-- Sources/ZIPFoundation/FileManager+ZIP.swift | 8 ++++---- .../ZIPFoundationFileAttributeTests.swift | 2 +- Tests/ZIPFoundationTests/ZIPFoundationProgressTests.swift | 2 +- Tests/ZIPFoundationTests/ZIPFoundationTests.swift | 4 ++-- 9 files changed, 18 insertions(+), 18 deletions(-) diff --git a/Package@swift-4.0.swift b/Package@swift-4.0.swift index 104a8a23..f831890b 100644 --- a/Package@swift-4.0.swift +++ b/Package@swift-4.0.swift @@ -1,7 +1,7 @@ // swift-tools-version:4.0 import PackageDescription -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) let dependencies: [Package.Dependency] = [] #else let dependencies: [Package.Dependency] = [.package(url: "https://github.com/IBM-Swift/CZlib.git", .exact("0.1.2"))] diff --git a/Sources/ZIPFoundation/Archive+MemoryFile.swift b/Sources/ZIPFoundation/Archive+MemoryFile.swift index ce188125..e7c9713d 100644 --- a/Sources/ZIPFoundation/Archive+MemoryFile.swift +++ b/Sources/ZIPFoundation/Archive+MemoryFile.swift @@ -33,7 +33,7 @@ class MemoryFile { let cookie = Unmanaged.passRetained(self) let writable = mode.count > 0 && (mode.first! != "r" || mode.last! == "+") let append = mode.count > 0 && mode.first! == "a" - #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(Android) + #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) || os(Android) let result = writable ? funopen(cookie.toOpaque(), readStub, writeStub, seekStub, closeStub) : funopen(cookie.toOpaque(), readStub, nil, seekStub, closeStub) @@ -99,7 +99,7 @@ private func closeStub(_ cookie: UnsafeMutableRawPointer?) -> Int32 { return 0 } -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(Android) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) || os(Android) private func readStub(_ cookie: UnsafeMutableRawPointer?, _ bytePtr: UnsafeMutablePointer?, _ count: Int32) -> Int32 { diff --git a/Sources/ZIPFoundation/Archive+Writing.swift b/Sources/ZIPFoundation/Archive+Writing.swift index b9e5c708..6f7cb58e 100644 --- a/Sources/ZIPFoundation/Archive+Writing.swift +++ b/Sources/ZIPFoundation/Archive+Writing.swift @@ -232,7 +232,7 @@ extension Archive { #endif } else { let fileManager = FileManager() - #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) + #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) do { _ = try fileManager.replaceItemAt(self.url, withItemAt: archive.url) } catch { diff --git a/Sources/ZIPFoundation/Data+Compression.swift b/Sources/ZIPFoundation/Data+Compression.swift index 70386203..f6f17e0e 100644 --- a/Sources/ZIPFoundation/Data+Compression.swift +++ b/Sources/ZIPFoundation/Data+Compression.swift @@ -66,7 +66,7 @@ extension Data { /// - consumer: A closure that processes the result of the compress operation. /// - Returns: The checksum of the processed content. public static func compress(size: Int64, bufferSize: Int, provider: Provider, consumer: Consumer) throws -> CRC32 { - #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) + #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) return try self.process(operation: COMPRESSION_STREAM_ENCODE, size: size, bufferSize: bufferSize, provider: provider, consumer: consumer) #else @@ -84,7 +84,7 @@ extension Data { /// - Returns: The checksum of the processed content. public static func decompress(size: Int64, bufferSize: Int, skipCRC32: Bool, provider: Provider, consumer: Consumer) throws -> CRC32 { - #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) + #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) return try self.process(operation: COMPRESSION_STREAM_DECODE, size: size, bufferSize: bufferSize, skipCRC32: skipCRC32, provider: provider, consumer: consumer) #else @@ -95,7 +95,7 @@ extension Data { // MARK: - Apple Platforms -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) import Compression extension Data { @@ -351,7 +351,7 @@ extension Data { } } - #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) + #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) #else mutating func withUnsafeMutableBytes(_ body: (UnsafeMutableRawBufferPointer) throws -> T) rethrows -> T { let count = self.count diff --git a/Sources/ZIPFoundation/Date+ZIP.swift b/Sources/ZIPFoundation/Date+ZIP.swift index e4719835..38e05dd1 100644 --- a/Sources/ZIPFoundation/Date+ZIP.swift +++ b/Sources/ZIPFoundation/Date+ZIP.swift @@ -66,7 +66,7 @@ extension Date { private extension Date { enum Constants { -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) static let absoluteTimeIntervalSince1970 = kCFAbsoluteTimeIntervalSince1970 #else static let absoluteTimeIntervalSince1970: Double = 978307200.0 @@ -77,7 +77,7 @@ private extension Date { extension stat { var lastAccessDate: Date { -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) return Date(timespec: st_atimespec) #else return Date(timespec: st_atim) diff --git a/Sources/ZIPFoundation/FileManager+ZIP.swift b/Sources/ZIPFoundation/FileManager+ZIP.swift index 6c139624..8cc8bcb3 100644 --- a/Sources/ZIPFoundation/FileManager+ZIP.swift +++ b/Sources/ZIPFoundation/FileManager+ZIP.swift @@ -169,7 +169,7 @@ extension FileManager { return } -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) guard let posixPermissions = attributes[.posixPermissions] as? NSNumber else { throw Entry.EntryError.missingPermissionsAttributeError } @@ -224,7 +224,7 @@ extension FileManager { let defaultPermissions = entryType == .directory ? defaultDirectoryPermissions : defaultFilePermissions var attributes = [.posixPermissions: defaultPermissions] as [FileAttributeKey: Any] // Certain keys are not yet supported in swift-corelibs -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) attributes[.modificationDate] = Date(dateTime: (fileDate, fileTime)) #endif let versionMadeBy = centralDirectoryStructure.versionMadeBy @@ -280,7 +280,7 @@ extension FileManager { let entryFileSystemRepresentation = fileManager.fileSystemRepresentation(withPath: url.path) var fileStat = stat() lstat(entryFileSystemRepresentation, &fileStat) -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) let modTimeSpec = fileStat.st_mtimespec #else let modTimeSpec = fileStat.st_mtim @@ -331,7 +331,7 @@ extension CocoaError { #if swift(>=4.2) #else -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) #else // The swift-corelibs-foundation version of NSError.swift was missing a convenience method to create diff --git a/Tests/ZIPFoundationTests/ZIPFoundationFileAttributeTests.swift b/Tests/ZIPFoundationTests/ZIPFoundationFileAttributeTests.swift index fcf2379d..6a960541 100644 --- a/Tests/ZIPFoundationTests/ZIPFoundationFileAttributeTests.swift +++ b/Tests/ZIPFoundationTests/ZIPFoundationFileAttributeTests.swift @@ -103,7 +103,7 @@ extension ZIPFoundationTests { } catch { XCTFail("Unexpected error while trying to transfer symlink attributes") } -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) do { var resourceValues = URLResourceValues() resourceValues.isUserImmutable = true diff --git a/Tests/ZIPFoundationTests/ZIPFoundationProgressTests.swift b/Tests/ZIPFoundationTests/ZIPFoundationProgressTests.swift index f372f001..36cf9250 100644 --- a/Tests/ZIPFoundationTests/ZIPFoundationProgressTests.swift +++ b/Tests/ZIPFoundationTests/ZIPFoundationProgressTests.swift @@ -10,7 +10,7 @@ import XCTest @testable import ZIPFoundation -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) extension ZIPFoundationTests { func testArchiveAddUncompressedEntryProgress() { diff --git a/Tests/ZIPFoundationTests/ZIPFoundationTests.swift b/Tests/ZIPFoundationTests/ZIPFoundationTests.swift index 8da9b775..0d1c5408 100644 --- a/Tests/ZIPFoundationTests/ZIPFoundationTests.swift +++ b/Tests/ZIPFoundationTests/ZIPFoundationTests.swift @@ -137,7 +137,7 @@ class ZIPFoundationTests: XCTestCase { } func runWithFileDescriptorLimit(_ limit: UInt64, handler: () -> Void) { - #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(Android) + #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) || os(Android) let fileNoFlag = RLIMIT_NOFILE #else let fileNoFlag = Int32(RLIMIT_NOFILE.rawValue) @@ -365,7 +365,7 @@ extension Archive { extension Data { static func makeRandomData(size: Int) -> Data { - #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) + #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) let bytes = [UInt32](repeating: 0, count: size).map { _ in UInt32.random(in: 0...UInt32.max) } #else let bytes = [UInt32](repeating: 0, count: size).map { _ in random() } From 0c363e442753f13b53de698d2e276fa9d2001994 Mon Sep 17 00:00:00 2001 From: Thomas Zoechling Date: Wed, 16 Aug 2023 08:30:18 +0200 Subject: [PATCH 2/9] Use `visionOS` as platform name in conditional compilation blocks --- Sources/ZIPFoundation/Archive+MemoryFile.swift | 4 ++-- Sources/ZIPFoundation/Archive+Writing.swift | 2 +- Sources/ZIPFoundation/Data+Compression.swift | 8 ++++---- Sources/ZIPFoundation/Date+ZIP.swift | 4 ++-- Sources/ZIPFoundation/FileManager+ZIP.swift | 8 ++++---- .../ZIPFoundationFileAttributeTests.swift | 2 +- Tests/ZIPFoundationTests/ZIPFoundationProgressTests.swift | 2 +- Tests/ZIPFoundationTests/ZIPFoundationTests.swift | 4 ++-- 8 files changed, 17 insertions(+), 17 deletions(-) diff --git a/Sources/ZIPFoundation/Archive+MemoryFile.swift b/Sources/ZIPFoundation/Archive+MemoryFile.swift index e7c9713d..08160a4c 100644 --- a/Sources/ZIPFoundation/Archive+MemoryFile.swift +++ b/Sources/ZIPFoundation/Archive+MemoryFile.swift @@ -33,7 +33,7 @@ class MemoryFile { let cookie = Unmanaged.passRetained(self) let writable = mode.count > 0 && (mode.first! != "r" || mode.last! == "+") let append = mode.count > 0 && mode.first! == "a" - #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) || os(Android) + #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) || os(Android) let result = writable ? funopen(cookie.toOpaque(), readStub, writeStub, seekStub, closeStub) : funopen(cookie.toOpaque(), readStub, nil, seekStub, closeStub) @@ -99,7 +99,7 @@ private func closeStub(_ cookie: UnsafeMutableRawPointer?) -> Int32 { return 0 } -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) || os(Android) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) || os(Android) private func readStub(_ cookie: UnsafeMutableRawPointer?, _ bytePtr: UnsafeMutablePointer?, _ count: Int32) -> Int32 { diff --git a/Sources/ZIPFoundation/Archive+Writing.swift b/Sources/ZIPFoundation/Archive+Writing.swift index 6f7cb58e..2a108cd4 100644 --- a/Sources/ZIPFoundation/Archive+Writing.swift +++ b/Sources/ZIPFoundation/Archive+Writing.swift @@ -232,7 +232,7 @@ extension Archive { #endif } else { let fileManager = FileManager() - #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) + #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) do { _ = try fileManager.replaceItemAt(self.url, withItemAt: archive.url) } catch { diff --git a/Sources/ZIPFoundation/Data+Compression.swift b/Sources/ZIPFoundation/Data+Compression.swift index f6f17e0e..ea47f72f 100644 --- a/Sources/ZIPFoundation/Data+Compression.swift +++ b/Sources/ZIPFoundation/Data+Compression.swift @@ -66,7 +66,7 @@ extension Data { /// - consumer: A closure that processes the result of the compress operation. /// - Returns: The checksum of the processed content. public static func compress(size: Int64, bufferSize: Int, provider: Provider, consumer: Consumer) throws -> CRC32 { - #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) + #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) return try self.process(operation: COMPRESSION_STREAM_ENCODE, size: size, bufferSize: bufferSize, provider: provider, consumer: consumer) #else @@ -84,7 +84,7 @@ extension Data { /// - Returns: The checksum of the processed content. public static func decompress(size: Int64, bufferSize: Int, skipCRC32: Bool, provider: Provider, consumer: Consumer) throws -> CRC32 { - #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) + #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) return try self.process(operation: COMPRESSION_STREAM_DECODE, size: size, bufferSize: bufferSize, skipCRC32: skipCRC32, provider: provider, consumer: consumer) #else @@ -95,7 +95,7 @@ extension Data { // MARK: - Apple Platforms -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) import Compression extension Data { @@ -351,7 +351,7 @@ extension Data { } } - #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) + #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) #else mutating func withUnsafeMutableBytes(_ body: (UnsafeMutableRawBufferPointer) throws -> T) rethrows -> T { let count = self.count diff --git a/Sources/ZIPFoundation/Date+ZIP.swift b/Sources/ZIPFoundation/Date+ZIP.swift index 38e05dd1..3d60b3a8 100644 --- a/Sources/ZIPFoundation/Date+ZIP.swift +++ b/Sources/ZIPFoundation/Date+ZIP.swift @@ -66,7 +66,7 @@ extension Date { private extension Date { enum Constants { -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) static let absoluteTimeIntervalSince1970 = kCFAbsoluteTimeIntervalSince1970 #else static let absoluteTimeIntervalSince1970: Double = 978307200.0 @@ -77,7 +77,7 @@ private extension Date { extension stat { var lastAccessDate: Date { -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) return Date(timespec: st_atimespec) #else return Date(timespec: st_atim) diff --git a/Sources/ZIPFoundation/FileManager+ZIP.swift b/Sources/ZIPFoundation/FileManager+ZIP.swift index 8cc8bcb3..4bd18ac6 100644 --- a/Sources/ZIPFoundation/FileManager+ZIP.swift +++ b/Sources/ZIPFoundation/FileManager+ZIP.swift @@ -169,7 +169,7 @@ extension FileManager { return } -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) guard let posixPermissions = attributes[.posixPermissions] as? NSNumber else { throw Entry.EntryError.missingPermissionsAttributeError } @@ -224,7 +224,7 @@ extension FileManager { let defaultPermissions = entryType == .directory ? defaultDirectoryPermissions : defaultFilePermissions var attributes = [.posixPermissions: defaultPermissions] as [FileAttributeKey: Any] // Certain keys are not yet supported in swift-corelibs -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) attributes[.modificationDate] = Date(dateTime: (fileDate, fileTime)) #endif let versionMadeBy = centralDirectoryStructure.versionMadeBy @@ -280,7 +280,7 @@ extension FileManager { let entryFileSystemRepresentation = fileManager.fileSystemRepresentation(withPath: url.path) var fileStat = stat() lstat(entryFileSystemRepresentation, &fileStat) -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) let modTimeSpec = fileStat.st_mtimespec #else let modTimeSpec = fileStat.st_mtim @@ -331,7 +331,7 @@ extension CocoaError { #if swift(>=4.2) #else -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) #else // The swift-corelibs-foundation version of NSError.swift was missing a convenience method to create diff --git a/Tests/ZIPFoundationTests/ZIPFoundationFileAttributeTests.swift b/Tests/ZIPFoundationTests/ZIPFoundationFileAttributeTests.swift index 6a960541..bd7cad7d 100644 --- a/Tests/ZIPFoundationTests/ZIPFoundationFileAttributeTests.swift +++ b/Tests/ZIPFoundationTests/ZIPFoundationFileAttributeTests.swift @@ -103,7 +103,7 @@ extension ZIPFoundationTests { } catch { XCTFail("Unexpected error while trying to transfer symlink attributes") } -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) do { var resourceValues = URLResourceValues() resourceValues.isUserImmutable = true diff --git a/Tests/ZIPFoundationTests/ZIPFoundationProgressTests.swift b/Tests/ZIPFoundationTests/ZIPFoundationProgressTests.swift index 36cf9250..68428872 100644 --- a/Tests/ZIPFoundationTests/ZIPFoundationProgressTests.swift +++ b/Tests/ZIPFoundationTests/ZIPFoundationProgressTests.swift @@ -10,7 +10,7 @@ import XCTest @testable import ZIPFoundation -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) extension ZIPFoundationTests { func testArchiveAddUncompressedEntryProgress() { diff --git a/Tests/ZIPFoundationTests/ZIPFoundationTests.swift b/Tests/ZIPFoundationTests/ZIPFoundationTests.swift index 0d1c5408..10dae33b 100644 --- a/Tests/ZIPFoundationTests/ZIPFoundationTests.swift +++ b/Tests/ZIPFoundationTests/ZIPFoundationTests.swift @@ -137,7 +137,7 @@ class ZIPFoundationTests: XCTestCase { } func runWithFileDescriptorLimit(_ limit: UInt64, handler: () -> Void) { - #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) || os(Android) + #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) || os(Android) let fileNoFlag = RLIMIT_NOFILE #else let fileNoFlag = Int32(RLIMIT_NOFILE.rawValue) @@ -365,7 +365,7 @@ extension Archive { extension Data { static func makeRandomData(size: Int) -> Data { - #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) + #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) let bytes = [UInt32](repeating: 0, count: size).map { _ in UInt32.random(in: 0...UInt32.max) } #else let bytes = [UInt32](repeating: 0, count: size).map { _ in random() } From 892f8bb017ac7fa7c9ff09d760dfb7d3ef98819e Mon Sep 17 00:00:00 2001 From: Thomas Zoechling Date: Wed, 16 Aug 2023 08:34:10 +0200 Subject: [PATCH 3/9] Add visionOS as supported platform in the Xcode project --- ZIPFoundation.xcodeproj/project.pbxproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ZIPFoundation.xcodeproj/project.pbxproj b/ZIPFoundation.xcodeproj/project.pbxproj index 5e5dfe8e..82531e42 100644 --- a/ZIPFoundation.xcodeproj/project.pbxproj +++ b/ZIPFoundation.xcodeproj/project.pbxproj @@ -402,7 +402,7 @@ OTHER_SWIFT_FLAGS = "-DXcode"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = ""; - SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator"; + SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator xrsimulator xros"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_VERSION = 4.0; @@ -488,7 +488,7 @@ OTHER_SWIFT_FLAGS = "-DXcode"; PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = ""; - SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator"; + SUPPORTED_PLATFORMS = "macosx iphoneos iphonesimulator appletvos appletvsimulator watchos watchsimulator xrsimulator xros"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_VERSION = 4.0; TVOS_DEPLOYMENT_TARGET = 12.0; From 2b183df0e0820f3b88df66d537bfb96720983d43 Mon Sep 17 00:00:00 2001 From: Thomas Zoechling Date: Wed, 16 Aug 2023 08:50:43 +0200 Subject: [PATCH 4/9] Update README --- Package@swift-4.0.swift | 2 +- README.md | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Package@swift-4.0.swift b/Package@swift-4.0.swift index f831890b..940ab34d 100644 --- a/Package@swift-4.0.swift +++ b/Package@swift-4.0.swift @@ -1,7 +1,7 @@ // swift-tools-version:4.0 import PackageDescription -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(xrOS) +#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) let dependencies: [Package.Dependency] = [] #else let dependencies: [Package.Dependency] = [.package(url: "https://github.com/IBM-Swift/CZlib.git", .exact("0.1.2"))] diff --git a/README.md b/README.md index 50990e7d..2fa6e617 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ [![Swift Package Manager compatible](https://img.shields.io/badge/SPM-compatible-brightgreen.svg)](https://github.com/apple/swift-package-manager) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) [![CocoaPods Compatible](https://img.shields.io/cocoapods/v/ZIPFoundation.svg)](https://cocoapods.org/pods/ZIPFoundation) -[![Platform](https://img.shields.io/badge/Platforms-macOS%20|%20iOS%20|%20tvOS%20|%20watchOS%20|%20Linux-lightgrey.svg)](https://github.com/weichsel/ZIPFoundation) +[![Platform](https://img.shields.io/badge/Platforms-macOS%20|%20iOS%20|%20tvOS%20|%20watchOS%20|%20visionOS%20|%20Linux-lightgrey.svg)](https://github.com/weichsel/ZIPFoundation) [![Twitter](https://img.shields.io/badge/twitter-@weichsel-blue.svg?style=flat)](http://twitter.com/weichsel) ZIP Foundation is a library to create, read and modify ZIP archive files. @@ -40,7 +40,7 @@ To learn more about the performance characteristics of the framework, you can re ## Requirements -- iOS 12.0+ / macOS 10.11+ / tvOS 12.0+ / watchOS 2.0+ +- iOS 12.0+ / macOS 10.11+ / tvOS 12.0+ / watchOS 2.0+ / visionOS 1.0+ - Or Linux with zlib development package - Xcode 11.0 - Swift 4.0 From 35c4759fee3328b4ba1da3287ae8190894cbf255 Mon Sep 17 00:00:00 2001 From: Thomas Zoechling Date: Wed, 16 Aug 2023 09:03:14 +0200 Subject: [PATCH 5/9] Sort platforms in conditional compilation directives --- Package.swift | 2 +- Sources/ZIPFoundation/Archive+MemoryFile.swift | 4 ++-- Sources/ZIPFoundation/Archive+Writing.swift | 2 +- Sources/ZIPFoundation/Data+Compression.swift | 8 ++++---- Sources/ZIPFoundation/Date+ZIP.swift | 4 ++-- Sources/ZIPFoundation/FileManager+ZIP.swift | 8 ++++---- Sources/ZIPFoundation/URL+ZIP.swift | 2 +- .../ZIPFoundationFileAttributeTests.swift | 2 +- Tests/ZIPFoundationTests/ZIPFoundationMemoryTests.swift | 4 ++-- Tests/ZIPFoundationTests/ZIPFoundationProgressTests.swift | 2 +- Tests/ZIPFoundationTests/ZIPFoundationTests.swift | 6 +++--- 11 files changed, 22 insertions(+), 22 deletions(-) diff --git a/Package.swift b/Package.swift index 26c76d06..d0746aaf 100644 --- a/Package.swift +++ b/Package.swift @@ -17,7 +17,7 @@ let targets: [Target] = [ let package = Package( name: "ZIPFoundation", platforms: [ - .macOS(.v10_11), .iOS(.v9), .tvOS(.v9), .watchOS(.v2) + .macOS(.v10_11), .iOS(.v9), .tvOS(.v9), .watchOS(.v2), .visionOS(.v1) ], products: [ .library(name: "ZIPFoundation", targets: ["ZIPFoundation"]) diff --git a/Sources/ZIPFoundation/Archive+MemoryFile.swift b/Sources/ZIPFoundation/Archive+MemoryFile.swift index 08160a4c..b49542c6 100644 --- a/Sources/ZIPFoundation/Archive+MemoryFile.swift +++ b/Sources/ZIPFoundation/Archive+MemoryFile.swift @@ -33,7 +33,7 @@ class MemoryFile { let cookie = Unmanaged.passRetained(self) let writable = mode.count > 0 && (mode.first! != "r" || mode.last! == "+") let append = mode.count > 0 && mode.first! == "a" - #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) || os(Android) + #if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS) || os(Android) let result = writable ? funopen(cookie.toOpaque(), readStub, writeStub, seekStub, closeStub) : funopen(cookie.toOpaque(), readStub, nil, seekStub, closeStub) @@ -99,7 +99,7 @@ private func closeStub(_ cookie: UnsafeMutableRawPointer?) -> Int32 { return 0 } -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) || os(Android) +#if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS) || os(Android) private func readStub(_ cookie: UnsafeMutableRawPointer?, _ bytePtr: UnsafeMutablePointer?, _ count: Int32) -> Int32 { diff --git a/Sources/ZIPFoundation/Archive+Writing.swift b/Sources/ZIPFoundation/Archive+Writing.swift index 2a108cd4..2ca51a83 100644 --- a/Sources/ZIPFoundation/Archive+Writing.swift +++ b/Sources/ZIPFoundation/Archive+Writing.swift @@ -232,7 +232,7 @@ extension Archive { #endif } else { let fileManager = FileManager() - #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) + #if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS) do { _ = try fileManager.replaceItemAt(self.url, withItemAt: archive.url) } catch { diff --git a/Sources/ZIPFoundation/Data+Compression.swift b/Sources/ZIPFoundation/Data+Compression.swift index ea47f72f..3bee1501 100644 --- a/Sources/ZIPFoundation/Data+Compression.swift +++ b/Sources/ZIPFoundation/Data+Compression.swift @@ -66,7 +66,7 @@ extension Data { /// - consumer: A closure that processes the result of the compress operation. /// - Returns: The checksum of the processed content. public static func compress(size: Int64, bufferSize: Int, provider: Provider, consumer: Consumer) throws -> CRC32 { - #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) + #if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS) return try self.process(operation: COMPRESSION_STREAM_ENCODE, size: size, bufferSize: bufferSize, provider: provider, consumer: consumer) #else @@ -84,7 +84,7 @@ extension Data { /// - Returns: The checksum of the processed content. public static func decompress(size: Int64, bufferSize: Int, skipCRC32: Bool, provider: Provider, consumer: Consumer) throws -> CRC32 { - #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) + #if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS) return try self.process(operation: COMPRESSION_STREAM_DECODE, size: size, bufferSize: bufferSize, skipCRC32: skipCRC32, provider: provider, consumer: consumer) #else @@ -95,7 +95,7 @@ extension Data { // MARK: - Apple Platforms -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) +#if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS) import Compression extension Data { @@ -351,7 +351,7 @@ extension Data { } } - #if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) + #if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS) #else mutating func withUnsafeMutableBytes(_ body: (UnsafeMutableRawBufferPointer) throws -> T) rethrows -> T { let count = self.count diff --git a/Sources/ZIPFoundation/Date+ZIP.swift b/Sources/ZIPFoundation/Date+ZIP.swift index 3d60b3a8..429a06c7 100644 --- a/Sources/ZIPFoundation/Date+ZIP.swift +++ b/Sources/ZIPFoundation/Date+ZIP.swift @@ -66,7 +66,7 @@ extension Date { private extension Date { enum Constants { -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) +#if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS) static let absoluteTimeIntervalSince1970 = kCFAbsoluteTimeIntervalSince1970 #else static let absoluteTimeIntervalSince1970: Double = 978307200.0 @@ -77,7 +77,7 @@ private extension Date { extension stat { var lastAccessDate: Date { -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) +#if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS) return Date(timespec: st_atimespec) #else return Date(timespec: st_atim) diff --git a/Sources/ZIPFoundation/FileManager+ZIP.swift b/Sources/ZIPFoundation/FileManager+ZIP.swift index 4bd18ac6..78a3142e 100644 --- a/Sources/ZIPFoundation/FileManager+ZIP.swift +++ b/Sources/ZIPFoundation/FileManager+ZIP.swift @@ -169,7 +169,7 @@ extension FileManager { return } -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) +#if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS) guard let posixPermissions = attributes[.posixPermissions] as? NSNumber else { throw Entry.EntryError.missingPermissionsAttributeError } @@ -224,7 +224,7 @@ extension FileManager { let defaultPermissions = entryType == .directory ? defaultDirectoryPermissions : defaultFilePermissions var attributes = [.posixPermissions: defaultPermissions] as [FileAttributeKey: Any] // Certain keys are not yet supported in swift-corelibs -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) +#if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS) attributes[.modificationDate] = Date(dateTime: (fileDate, fileTime)) #endif let versionMadeBy = centralDirectoryStructure.versionMadeBy @@ -280,7 +280,7 @@ extension FileManager { let entryFileSystemRepresentation = fileManager.fileSystemRepresentation(withPath: url.path) var fileStat = stat() lstat(entryFileSystemRepresentation, &fileStat) -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) +#if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS) let modTimeSpec = fileStat.st_mtimespec #else let modTimeSpec = fileStat.st_mtim @@ -331,7 +331,7 @@ extension CocoaError { #if swift(>=4.2) #else -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) +#if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS) #else // The swift-corelibs-foundation version of NSError.swift was missing a convenience method to create diff --git a/Sources/ZIPFoundation/URL+ZIP.swift b/Sources/ZIPFoundation/URL+ZIP.swift index d72f47e4..bc2febbb 100644 --- a/Sources/ZIPFoundation/URL+ZIP.swift +++ b/Sources/ZIPFoundation/URL+ZIP.swift @@ -13,7 +13,7 @@ import Foundation extension URL { static func temporaryReplacementDirectoryURL(for archive: Archive) -> URL { - #if swift(>=5.0) || os(macOS) || os(iOS) || os(watchOS) || os(tvOS) + #if swift(>=5.0) || os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS) if archive.url.isFileURL, let tempDir = try? FileManager().url(for: .itemReplacementDirectory, in: .userDomainMask, appropriateFor: archive.url, create: true) { diff --git a/Tests/ZIPFoundationTests/ZIPFoundationFileAttributeTests.swift b/Tests/ZIPFoundationTests/ZIPFoundationFileAttributeTests.swift index bd7cad7d..193e352a 100644 --- a/Tests/ZIPFoundationTests/ZIPFoundationFileAttributeTests.swift +++ b/Tests/ZIPFoundationTests/ZIPFoundationFileAttributeTests.swift @@ -103,7 +103,7 @@ extension ZIPFoundationTests { } catch { XCTFail("Unexpected error while trying to transfer symlink attributes") } -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) +#if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS) do { var resourceValues = URLResourceValues() resourceValues.isUserImmutable = true diff --git a/Tests/ZIPFoundationTests/ZIPFoundationMemoryTests.swift b/Tests/ZIPFoundationTests/ZIPFoundationMemoryTests.swift index 17a9972a..6d666586 100644 --- a/Tests/ZIPFoundationTests/ZIPFoundationMemoryTests.swift +++ b/Tests/ZIPFoundationTests/ZIPFoundationMemoryTests.swift @@ -111,7 +111,7 @@ extension ZIPFoundationTests { var didCatchExpectedError = false // Trigger the code path that is taken if funopen() fails // We can only do this on Apple platforms - #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) + #if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS) self.runWithoutMemory { do { try archive.remove(entryToRemove) @@ -145,7 +145,7 @@ extension ZIPFoundationTests { XCTAssertNil(invalidArchive) // Trigger the code path that is taken if funopen() fails // We can only do this on Apple platforms - #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) + #if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS) var unallocatableArchive: Archive? self.runWithoutMemory { unallocatableArchive = Archive(data: data, accessMode: .read) diff --git a/Tests/ZIPFoundationTests/ZIPFoundationProgressTests.swift b/Tests/ZIPFoundationTests/ZIPFoundationProgressTests.swift index 68428872..b8e4ab8a 100644 --- a/Tests/ZIPFoundationTests/ZIPFoundationProgressTests.swift +++ b/Tests/ZIPFoundationTests/ZIPFoundationProgressTests.swift @@ -10,7 +10,7 @@ import XCTest @testable import ZIPFoundation -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) +#if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS) extension ZIPFoundationTests { func testArchiveAddUncompressedEntryProgress() { diff --git a/Tests/ZIPFoundationTests/ZIPFoundationTests.swift b/Tests/ZIPFoundationTests/ZIPFoundationTests.swift index 10dae33b..0de8776a 100644 --- a/Tests/ZIPFoundationTests/ZIPFoundationTests.swift +++ b/Tests/ZIPFoundationTests/ZIPFoundationTests.swift @@ -152,7 +152,7 @@ class ZIPFoundationTests: XCTestCase { } func runWithoutMemory(handler: () -> Void) { - #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) + #if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS) let systemAllocator = CFAllocatorGetDefault().takeUnretainedValue() CFAllocatorSetDefault(kCFAllocatorNull) defer { CFAllocatorSetDefault(systemAllocator) } @@ -179,7 +179,7 @@ class ZIPFoundationTests: XCTestCase { extension ZIPFoundationTests { // From https://oleb.net/blog/2017/03/keeping-xctest-in-sync/ func testLinuxTestSuiteIncludesAllTests() { - #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) + #if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS) let thisClass = type(of: self) let linuxCount = thisClass.allTests.count let darwinCount = Int(thisClass.defaultTestSuite.testCaseCount) @@ -296,7 +296,7 @@ extension ZIPFoundationTests { } static var darwinOnlyTests: [(String, (ZIPFoundationTests) -> () throws -> Void)] { - #if os(macOS) || os(iOS) || os(tvOS) || os(watchOS) + #if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS) return [ ("testFileModificationDate", testFileModificationDate), ("testFileModificationDateHelperMethods", testFileModificationDateHelperMethods), From 22ed01eaa5cc13ea67b11bfe3eda17b04625fc97 Mon Sep 17 00:00:00 2001 From: Thomas Zoechling Date: Wed, 16 Aug 2023 09:13:33 +0200 Subject: [PATCH 6/9] Bump swift-tools-version to 5.9 for visionOS support --- Package.swift | 2 +- Package@swift-4.0.swift | 2 +- Package@swift-5.0.swift | 27 +++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) create mode 100644 Package@swift-5.0.swift diff --git a/Package.swift b/Package.swift index d0746aaf..7d87ca7e 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.0 +// swift-tools-version:5.9 import PackageDescription #if canImport(Compression) diff --git a/Package@swift-4.0.swift b/Package@swift-4.0.swift index 940ab34d..94e0c3e1 100644 --- a/Package@swift-4.0.swift +++ b/Package@swift-4.0.swift @@ -1,7 +1,7 @@ // swift-tools-version:4.0 import PackageDescription -#if os(macOS) || os(iOS) || os(watchOS) || os(tvOS) || os(visionOS) +#if os(macOS) || os(iOS) || os(tvOS) || os(visionOS) || os(watchOS) let dependencies: [Package.Dependency] = [] #else let dependencies: [Package.Dependency] = [.package(url: "https://github.com/IBM-Swift/CZlib.git", .exact("0.1.2"))] diff --git a/Package@swift-5.0.swift b/Package@swift-5.0.swift new file mode 100644 index 00000000..26c76d06 --- /dev/null +++ b/Package@swift-5.0.swift @@ -0,0 +1,27 @@ +// swift-tools-version:5.0 +import PackageDescription + +#if canImport(Compression) +let targets: [Target] = [ + .target(name: "ZIPFoundation"), + .testTarget(name: "ZIPFoundationTests", dependencies: ["ZIPFoundation"]) +] +#else +let targets: [Target] = [ + .systemLibrary(name: "CZLib", pkgConfig: "zlib", providers: [.brew(["zlib"]), .apt(["zlib"])]), + .target(name: "ZIPFoundation", dependencies: ["CZLib"], cSettings: [.define("_GNU_SOURCE", to: "1")]), + .testTarget(name: "ZIPFoundationTests", dependencies: ["ZIPFoundation"]) +] +#endif + +let package = Package( + name: "ZIPFoundation", + platforms: [ + .macOS(.v10_11), .iOS(.v9), .tvOS(.v9), .watchOS(.v2) + ], + products: [ + .library(name: "ZIPFoundation", targets: ["ZIPFoundation"]) + ], + targets: targets, + swiftLanguageVersions: [.v4, .v4_2, .v5] +) From de9b33552426c3b0adb9048da35c218705d358a6 Mon Sep 17 00:00:00 2001 From: Thomas Zoechling Date: Wed, 16 Aug 2023 09:40:32 +0200 Subject: [PATCH 7/9] Modernize test matrix --- .github/workflows/swift.yml | 6 +++--- Package@swift-5.8.swift | 27 +++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) create mode 100644 Package@swift-5.8.swift diff --git a/.github/workflows/swift.yml b/.github/workflows/swift.yml index 7dd1c648..40aa48ac 100644 --- a/.github/workflows/swift.yml +++ b/.github/workflows/swift.yml @@ -10,8 +10,8 @@ jobs: Xcode: strategy: matrix: - xcode_version: ['13.2.1', '13.1', '13.0', '12.5.1', '12.4', '11.7'] - runs-on: macos-11 + xcode_version: ['13.3.1', '13.4', '14.0.1', '14.1', '14.2'] + runs-on: macos-12 env: DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode_version }}.app steps: @@ -22,7 +22,7 @@ jobs: Linux: strategy: matrix: - tag: ['5.1', '5.2', '5.3'] + tag: ['5.1', '5.3', '5.8'] runs-on: ubuntu-latest container: image: swift:${{ matrix.tag }} diff --git a/Package@swift-5.8.swift b/Package@swift-5.8.swift new file mode 100644 index 00000000..ac62994c --- /dev/null +++ b/Package@swift-5.8.swift @@ -0,0 +1,27 @@ +// swift-tools-version:5.8 +import PackageDescription + +#if canImport(Compression) +let targets: [Target] = [ + .target(name: "ZIPFoundation"), + .testTarget(name: "ZIPFoundationTests", dependencies: ["ZIPFoundation"]) +] +#else +let targets: [Target] = [ + .systemLibrary(name: "CZLib", pkgConfig: "zlib", providers: [.brew(["zlib"]), .apt(["zlib"])]), + .target(name: "ZIPFoundation", dependencies: ["CZLib"], cSettings: [.define("_GNU_SOURCE", to: "1")]), + .testTarget(name: "ZIPFoundationTests", dependencies: ["ZIPFoundation"]) +] +#endif + +let package = Package( + name: "ZIPFoundation", + platforms: [ + .macOS(.v10_11), .iOS(.v9), .tvOS(.v9), .watchOS(.v2) + ], + products: [ + .library(name: "ZIPFoundation", targets: ["ZIPFoundation"]) + ], + targets: targets, + swiftLanguageVersions: [.v4, .v4_2, .v5] +) From dc15c256877b3c73642e972af687fa47a5274bb8 Mon Sep 17 00:00:00 2001 From: Thomas Zoechling Date: Wed, 16 Aug 2023 09:58:17 +0200 Subject: [PATCH 8/9] Only use `.visionOS` as platform when using a toolchain with version >=5.9 --- Package.swift | 4 +-- Package@swift-5.8.swift | 27 ------------------- ...swift-5.0.swift => Package@swift-5.9.swift | 4 +-- 3 files changed, 4 insertions(+), 31 deletions(-) delete mode 100644 Package@swift-5.8.swift rename Package@swift-5.0.swift => Package@swift-5.9.swift (87%) diff --git a/Package.swift b/Package.swift index 7d87ca7e..26c76d06 100644 --- a/Package.swift +++ b/Package.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.9 +// swift-tools-version:5.0 import PackageDescription #if canImport(Compression) @@ -17,7 +17,7 @@ let targets: [Target] = [ let package = Package( name: "ZIPFoundation", platforms: [ - .macOS(.v10_11), .iOS(.v9), .tvOS(.v9), .watchOS(.v2), .visionOS(.v1) + .macOS(.v10_11), .iOS(.v9), .tvOS(.v9), .watchOS(.v2) ], products: [ .library(name: "ZIPFoundation", targets: ["ZIPFoundation"]) diff --git a/Package@swift-5.8.swift b/Package@swift-5.8.swift deleted file mode 100644 index ac62994c..00000000 --- a/Package@swift-5.8.swift +++ /dev/null @@ -1,27 +0,0 @@ -// swift-tools-version:5.8 -import PackageDescription - -#if canImport(Compression) -let targets: [Target] = [ - .target(name: "ZIPFoundation"), - .testTarget(name: "ZIPFoundationTests", dependencies: ["ZIPFoundation"]) -] -#else -let targets: [Target] = [ - .systemLibrary(name: "CZLib", pkgConfig: "zlib", providers: [.brew(["zlib"]), .apt(["zlib"])]), - .target(name: "ZIPFoundation", dependencies: ["CZLib"], cSettings: [.define("_GNU_SOURCE", to: "1")]), - .testTarget(name: "ZIPFoundationTests", dependencies: ["ZIPFoundation"]) -] -#endif - -let package = Package( - name: "ZIPFoundation", - platforms: [ - .macOS(.v10_11), .iOS(.v9), .tvOS(.v9), .watchOS(.v2) - ], - products: [ - .library(name: "ZIPFoundation", targets: ["ZIPFoundation"]) - ], - targets: targets, - swiftLanguageVersions: [.v4, .v4_2, .v5] -) diff --git a/Package@swift-5.0.swift b/Package@swift-5.9.swift similarity index 87% rename from Package@swift-5.0.swift rename to Package@swift-5.9.swift index 26c76d06..7d87ca7e 100644 --- a/Package@swift-5.0.swift +++ b/Package@swift-5.9.swift @@ -1,4 +1,4 @@ -// swift-tools-version:5.0 +// swift-tools-version:5.9 import PackageDescription #if canImport(Compression) @@ -17,7 +17,7 @@ let targets: [Target] = [ let package = Package( name: "ZIPFoundation", platforms: [ - .macOS(.v10_11), .iOS(.v9), .tvOS(.v9), .watchOS(.v2) + .macOS(.v10_11), .iOS(.v9), .tvOS(.v9), .watchOS(.v2), .visionOS(.v1) ], products: [ .library(name: "ZIPFoundation", targets: ["ZIPFoundation"]) From 1f10742b8b02bd006747b1d39d41e4725da60898 Mon Sep 17 00:00:00 2001 From: Thomas Zoechling Date: Wed, 16 Aug 2023 11:09:48 +0200 Subject: [PATCH 9/9] Improve test reliability --- .../ZIPFoundationFileManagerTests.swift | 25 ++++++++++++++++--- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/Tests/ZIPFoundationTests/ZIPFoundationFileManagerTests.swift b/Tests/ZIPFoundationTests/ZIPFoundationFileManagerTests.swift index c1ee7539..8c548647 100755 --- a/Tests/ZIPFoundationTests/ZIPFoundationFileManagerTests.swift +++ b/Tests/ZIPFoundationTests/ZIPFoundationFileManagerTests.swift @@ -202,10 +202,11 @@ extension ZIPFoundationTests { } let shellZIPURL = shellZIP(directoryAtURL: testBundleURL) - let shellZIPInfos = Set(ZIPInfo.makeZIPInfos(forArchiveAtURL: shellZIPURL, mode: .shellParsing)) - let builtInZIPInfos = Set(ZIPInfo.makeZIPInfos(forArchiveAtURL: builtInZIPURL, mode: .directoryIteration)) - let diff = builtInZIPInfos.symmetricDifference(shellZIPInfos) - XCTAssert(diff.count == 0) + let shellZIPInfos = ZIPInfo.makeZIPInfos(forArchiveAtURL: shellZIPURL, mode: .shellParsing) + .sorted { $0.path < $1.path } + let builtInZIPInfos = ZIPInfo.makeZIPInfos(forArchiveAtURL: builtInZIPURL, mode: .directoryIteration) + .sorted { $0.path < $1.path } + XCTAssert(shellZIPInfos == builtInZIPInfos) #endif } } @@ -302,6 +303,22 @@ private struct ZIPInfo: Hashable { } } +extension ZIPInfo: Equatable { + + static func == (lhs: Self, rhs: Self) -> Bool { + let hasSamePath = lhs.path == rhs.path + let hasSameSize = lhs.size == rhs.size + // ZIP date/timesstamps have very low resolution. We have to compare with some leeway. + let startDate = lhs.modificationDate.addingTimeInterval(-2) + let endDate = lhs.modificationDate.addingTimeInterval(+2) + let dateRange = startDate...endDate + let hasSameDate = dateRange.contains(rhs.modificationDate) + return hasSamePath && + hasSameSize && + hasSameDate + } +} + private extension URL { static func makeRelativePath(fromPath path: String, relativeToPath basePath: String, isDirectory: Bool) -> String {