Skip to content

Commit ac14d33

Browse files
authored
Bump macOS minimum version to v11 (#11)
1 parent 2c4ab8f commit ac14d33

File tree

8 files changed

+33
-80
lines changed

8 files changed

+33
-80
lines changed

.github/workflows/swift.yml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,17 @@ name: Swift
22

33
on:
44
push:
5-
branches: [development]
5+
branches: [development, develop]
66
pull_request:
7-
branches: [development]
7+
branches: [development, develop]
88

99
jobs:
1010
Xcode:
1111
strategy:
12+
fail-fast: false
1213
matrix:
13-
xcode_version: ['13.3.1', '13.4', '14.0.1', '14.1', '14.2']
14-
runs-on: macos-12
14+
xcode_version: ['16.2']
15+
runs-on: macos-14
1516
env:
1617
DEVELOPER_DIR: /Applications/Xcode_${{ matrix.xcode_version }}.app
1718
steps:
@@ -20,9 +21,12 @@ jobs:
2021
- run: swift test -c release -Xswiftc -enable-testing
2122

2223
Linux:
24+
# Linux is disabled for this fork
25+
if: false
2326
strategy:
27+
fail-fast: false
2428
matrix:
25-
tag: ['5.1', '5.2', '5.3', '5.4', '5.5', '5.6', '5.7', '5.8']
29+
tag: ['5.10']
2630
runs-on: ubuntu-latest
2731
container:
2832
image: swift:${{ matrix.tag }}

Package.swift

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ let targets: [Target] = [
1313
#else
1414
let targets: [Target] = [
1515
.systemLibrary(name: "CZLib", pkgConfig: "zlib", providers: [.brew(["zlib"]), .apt(["zlib"])]),
16-
.target(name: "ZIPFoundation", dependencies: ["CZLib"], cSettings: [.define("_GNU_SOURCE", to: "1")]),
17-
.testTarget(name: "ZIPFoundationTests", dependencies: ["ZIPFoundation"])
16+
.target(name: "ReadiumZIPFoundation", dependencies: ["CZLib"], path: "Sources/ZIPFoundation", cSettings: [.define("_GNU_SOURCE", to: "1")]),
17+
.testTarget(name: "ReadiumZIPFoundationTests", dependencies: ["ReadiumZIPFoundation"])
1818
]
1919
#endif
2020

2121
let package = Package(
2222
name: "ReadiumZIPFoundation",
2323
platforms: [
24-
.macOS(.v10_13), .iOS(.v13), .tvOS(.v12), .watchOS(.v4), .visionOS(.v1)
24+
.macOS(.v11), .iOS(.v13), .tvOS(.v12), .watchOS(.v4), .visionOS(.v1)
2525
],
2626
products: [
2727
.library(name: "ReadiumZIPFoundation", targets: ["ReadiumZIPFoundation"])

Sources/ZIPFoundation/Data+Compression.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ extension Data {
7070
return try await self.process(operation: COMPRESSION_STREAM_ENCODE, size: size, bufferSize: bufferSize,
7171
provider: provider, consumer: consumer)
7272
#else
73-
return try self.encode(size: size, bufferSize: bufferSize, provider: provider, consumer: consumer)
73+
return try await self.encode(size: size, bufferSize: bufferSize, provider: provider, consumer: consumer)
7474
#endif
7575
}
7676

@@ -88,7 +88,7 @@ extension Data {
8888
return try await self.process(operation: COMPRESSION_STREAM_DECODE, size: size, bufferSize: bufferSize,
8989
skipCRC32: skipCRC32, provider: provider, consumer: consumer)
9090
#else
91-
return try self.decode(bufferSize: bufferSize, skipCRC32: skipCRC32, provider: provider, consumer: consumer)
91+
return try await self.decode(bufferSize: bufferSize, skipCRC32: skipCRC32, provider: provider, consumer: consumer)
9292
#endif
9393
}
9494
}
@@ -166,7 +166,7 @@ private extension compression_stream {
166166
import CZlib
167167

168168
extension Data {
169-
static func encode(size: Int64, bufferSize: Int, provider: Provider, consumer: Consumer) throws -> CRC32 {
169+
static func encode(size: Int64, bufferSize: Int, provider: Provider, consumer: Consumer) async throws -> CRC32 {
170170
var stream = z_stream()
171171
let streamSize = Int32(MemoryLayout<z_stream>.size)
172172
var result = deflateInit2_(&stream, Z_DEFAULT_COMPRESSION,
@@ -178,7 +178,7 @@ extension Data {
178178
var zipCRC32 = CRC32(0)
179179
repeat {
180180
let readSize = Int(Swift.min((size - position), Int64(bufferSize)))
181-
var inputChunk = try provider(position, readSize)
181+
var inputChunk = try await provider(position, readSize)
182182
zipCRC32 = inputChunk.crc32(checksum: zipCRC32)
183183
stream.avail_in = UInt32(inputChunk.count)
184184
try inputChunk.withUnsafeMutableBytes { (rawBufferPointer) in
@@ -206,15 +206,15 @@ extension Data {
206206
guard result >= Z_OK else { throw CompressionError.corruptedData }
207207

208208
outputChunk.count = bufferSize - Int(stream.avail_out)
209-
try consumer(outputChunk)
209+
try await consumer(outputChunk)
210210
} while stream.avail_out == 0
211211
}
212212
position += Int64(readSize)
213213
} while flush != Z_FINISH
214214
return zipCRC32
215215
}
216216

217-
static func decode(bufferSize: Int, skipCRC32: Bool, provider: Provider, consumer: Consumer) throws -> CRC32 {
217+
static func decode(bufferSize: Int, skipCRC32: Bool, provider: Provider, consumer: Consumer) async throws -> CRC32 {
218218
var stream = z_stream()
219219
let streamSize = Int32(MemoryLayout<z_stream>.size)
220220
var result = inflateInit2_(&stream, -MAX_WBITS, ZLIB_VERSION, streamSize)
@@ -224,7 +224,7 @@ extension Data {
224224
var position: Int64 = 0
225225
repeat {
226226
stream.avail_in = UInt32(bufferSize)
227-
var chunk = try provider(position, bufferSize)
227+
var chunk = try await provider(position, bufferSize)
228228
position += Int64(chunk.count)
229229
try chunk.withUnsafeMutableBytes { (rawBufferPointer) in
230230
if let baseAddress = rawBufferPointer.baseAddress, rawBufferPointer.count > 0 {
@@ -249,7 +249,7 @@ extension Data {
249249
}
250250
let remainingLength = UInt32(bufferSize) - stream.avail_out
251251
outputData.count = Int(remainingLength)
252-
try consumer(outputData)
252+
try await consumer(outputData)
253253
if !skipCRC32 { unzipCRC32 = outputData.crc32(checksum: unzipCRC32) }
254254
} while stream.avail_out == 0
255255
}

Sources/ZIPFoundation/Data+Serialization.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@ public typealias FILEPointer = OpaquePointer
1616
public typealias FILEPointer = UnsafeMutablePointer<FILE>
1717
#endif
1818

19+
#if swift(>=6)
1920
extension FILEPointer: @unchecked @retroactive Sendable {}
21+
#else
22+
extension FILEPointer: @unchecked Sendable {}
23+
#endif
2024

2125
protocol DataSerializable {
2226
static var size: Int { get }

Tests/LinuxMain.swift

Lines changed: 0 additions & 6 deletions
This file was deleted.

Tests/ZIPFoundationTests/ZIPFoundationFileManagerTests.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ extension ZIPFoundationTests {
167167
// On Darwin platforms, we want the same behavior as the system-provided ZIP utilities.
168168
// On the Mac, this includes the graphical Archive Utility as well as the `ditto`
169169
// command line tool.
170-
func testConsistentBehaviorWithSystemZIPUtilities() {
170+
func testConsistentBehaviorWithSystemZIPUtilities() async {
171171
#if os(macOS)
172172
// We use a macOS framework bundle here because it covers a lot of file system edge cases like
173173
// double-symlinked directories etc.
@@ -176,7 +176,7 @@ extension ZIPFoundationTests {
176176
let builtInZIPURL = URL(fileURLWithPath: NSTemporaryDirectory())
177177
.appendingPathComponent(UUID().uuidString)
178178
.appendingPathExtension("zip")
179-
try? fileManager.zipItem(at: testBundleURL, to: builtInZIPURL)
179+
try? await fileManager.zipItem(at: testBundleURL, to: builtInZIPURL)
180180

181181
func shellZIP(directoryAtURL url: URL) -> URL {
182182
let zipTask = Process()
@@ -194,9 +194,9 @@ extension ZIPFoundationTests {
194194
}
195195

196196
let shellZIPURL = shellZIP(directoryAtURL: testBundleURL)
197-
let shellZIPInfos = ZIPInfo.makeZIPInfos(forArchiveAtURL: shellZIPURL, mode: .shellParsing)
197+
let shellZIPInfos = await ZIPInfo.makeZIPInfos(forArchiveAtURL: shellZIPURL, mode: .shellParsing)
198198
.sorted { $0.path < $1.path }
199-
let builtInZIPInfos = ZIPInfo.makeZIPInfos(forArchiveAtURL: builtInZIPURL, mode: .directoryIteration)
199+
let builtInZIPInfos = await ZIPInfo.makeZIPInfos(forArchiveAtURL: builtInZIPURL, mode: .directoryIteration)
200200
.sorted { $0.path < $1.path }
201201
XCTAssert(shellZIPInfos == builtInZIPInfos)
202202
#endif
@@ -242,15 +242,15 @@ private struct ZIPInfo: Hashable {
242242
self.path = fields[7].trimmingCharacters(in: .whitespacesAndNewlines)
243243
}
244244

245-
static func makeZIPInfos(forArchiveAtURL url: URL, mode: Mode) -> [ZIPInfo] {
245+
static func makeZIPInfos(forArchiveAtURL url: URL, mode: Mode) async -> [ZIPInfo] {
246246

247-
func directoryZIPInfos(forArchiveAtURL url: URL) -> [ZIPInfo] {
247+
func directoryZIPInfos(forArchiveAtURL url: URL) async -> [ZIPInfo] {
248248
let fileManager = FileManager()
249249
let tempDirectoryURL = URL(fileURLWithPath: NSTemporaryDirectory())
250250
.standardizedFileURL
251251
.appendingPathComponent(UUID().uuidString)
252252
let keys: [URLResourceKey] = [.fileSizeKey, .creationDateKey, .isDirectoryKey, .pathKey]
253-
try? fileManager.unzipItem(at: url, to: tempDirectoryURL)
253+
try? await fileManager.unzipItem(at: url, to: tempDirectoryURL)
254254
guard let enumerator = fileManager.enumerator(at: tempDirectoryURL, includingPropertiesForKeys: keys)
255255
else { return [] }
256256

@@ -288,7 +288,7 @@ private struct ZIPInfo: Hashable {
288288

289289
switch mode {
290290
case .directoryIteration:
291-
return directoryZIPInfos(forArchiveAtURL: url)
291+
return await directoryZIPInfos(forArchiveAtURL: url)
292292
case .shellParsing:
293293
return shellZIPInfos(forArchiveAtURL: url)
294294
}

Tests/ZIPFoundationTests/ZIPFoundationTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ extension ZIPFoundationTests {
310310
// ("testUnzipItemProgress", testUnzipItemProgress),
311311
("testConsistentBehaviorWithSystemZIPUtilities", testConsistentBehaviorWithSystemZIPUtilities),
312312
// ("testRemoveEntryProgress", testRemoveEntryProgress),
313-
("testReplaceCurrentArchiveWithArchiveCrossLink", testReplaceCurrentArchiveWithArchiveCrossLink),
313+
// ("testReplaceCurrentArchiveWithArchiveCrossLink", testReplaceCurrentArchiveWithArchiveCrossLink),
314314
// ("testArchiveAddUncompressedEntryProgress", testArchiveAddUncompressedEntryProgress),
315315
// ("testArchiveAddCompressedEntryProgress", testArchiveAddCompressedEntryProgress),
316316
// ("testZIP64ArchiveAddEntryProgress", testZIP64ArchiveAddEntryProgress),

Tests/ZIPFoundationTests/ZIPFoundationWritingTests.swift

Lines changed: 0 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -293,53 +293,4 @@ extension ZIPFoundationTests {
293293
throwsErrorWithCode: .EACCES)
294294
}
295295
}
296-
297-
func testReplaceCurrentArchiveWithArchiveCrossLink() {
298-
#if os(macOS)
299-
let createVolumeExpectation = expectation(description: "Creation of temporary additional volume")
300-
let unmountVolumeExpectation = expectation(description: "Unmount temporary additional volume")
301-
let tempDir = URL(fileURLWithPath: NSTemporaryDirectory()).appendingPathComponent(UUID().uuidString)
302-
do {
303-
try FileManager.default.createDirectory(at: tempDir, withIntermediateDirectories: true, attributes: nil)
304-
let volName = "Test_\(UUID().uuidString)"
305-
let task = try NSUserScriptTask.makeVolumeCreationTask(at: tempDir, volumeName: volName)
306-
task.execute { (error) in
307-
guard error == nil else {
308-
XCTFail("\(String(describing: error))")
309-
return
310-
}
311-
let vol2URL = URL(fileURLWithPath: "/Volumes/\(volName)")
312-
defer {
313-
let options: FileManager.UnmountOptions = [.allPartitionsAndEjectDisk, .withoutUI]
314-
FileManager.default.unmountVolume(at: vol2URL, options:
315-
options, completionHandler: { (error) in
316-
guard error == nil else {
317-
XCTFail("\(String(describing: error))")
318-
return
319-
}
320-
unmountVolumeExpectation.fulfill()
321-
})
322-
}
323-
let vol1ArchiveURL = tempDir.appendingPathComponent("vol1Archive")
324-
let vol2ArchiveURL = vol2URL.appendingPathComponent("vol2Archive")
325-
do {
326-
let vol1Archive = try Archive(url: vol1ArchiveURL, accessMode: .create)
327-
let vol2Archive = try Archive(url: vol2ArchiveURL, accessMode: .create)
328-
try vol1Archive.replaceCurrentArchive(with: vol2Archive)
329-
} catch {
330-
type(of: self).tearDown()
331-
XCTFail("\(String(describing: error))")
332-
return
333-
}
334-
createVolumeExpectation.fulfill()
335-
}
336-
} catch {
337-
XCTFail("\(error)")
338-
return
339-
}
340-
defer { try? FileManager.default.removeItem(at: tempDir) }
341-
342-
waitForExpectations(timeout: 30.0)
343-
#endif
344-
}
345296
}

0 commit comments

Comments
 (0)