Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Swift 6 Support #345

Open
wants to merge 6 commits into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,3 +68,4 @@ fastlane/test_output

# Swift Package Manager
.swiftpm
.DS_Store
27 changes: 27 additions & 0 deletions [email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// swift-tools-version:6.0
import PackageDescription

#if canImport(Compression)
let targets: [Target] = [
.target(name: "ZIPFoundation",
resources: [
.copy("Resources/PrivacyInfo.xcprivacy")
]),
.testTarget(name: "ZIPFoundationTests", dependencies: ["ZIPFoundation"], exclude: ["Resources"])
]
#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",
products: [
.library(name: "ZIPFoundation", targets: ["ZIPFoundation"])
],
targets: targets,
swiftLanguageModes: [.v5, .v6]
)
5 changes: 5 additions & 0 deletions Sources/ZIPFoundation/Archive+ZIP64.swift
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,13 @@ extension Archive.ZIP64EndOfCentralDirectory {
}

/// Properties that represent the maximum value of each field
#if swift(>=6.0)
nonisolated(unsafe) var maxUInt32 = UInt32.max
nonisolated(unsafe) var maxUInt16 = UInt16.max
#else
var maxUInt32 = UInt32.max
var maxUInt16 = UInt16.max
#endif

var maxCompressedSize: UInt32 { maxUInt32 }
var maxUncompressedSize: UInt32 { maxUInt32 }
Expand Down
7 changes: 4 additions & 3 deletions Tests/ZIPFoundationTests/ZIPFoundationTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ enum AdditionalDataError: Error {
case invalidDataError
}

class ZIPFoundationTests: XCTestCase {
class ZIPFoundationTests: XCTestCase, @unchecked Sendable {

class var testBundle: Bundle {
return Bundle(for: self)
}

static var tempZipDirectoryURL: URL = {
static let tempZipDirectoryURL: URL = {
let processInfo = ProcessInfo.processInfo
var tempZipDirectory = URL(fileURLWithPath: NSTemporaryDirectory())
tempZipDirectory.appendPathComponent("ZipTempDirectory")
Expand All @@ -34,7 +35,7 @@ class ZIPFoundationTests: XCTestCase {
}()

static var resourceDirectoryURL: URL {
var resourceDirectoryURL = URL(fileURLWithPath: #file)
var resourceDirectoryURL = URL(fileURLWithPath: #filePath)
resourceDirectoryURL.deleteLastPathComponent()
resourceDirectoryURL.appendPathComponent("Resources")
return resourceDirectoryURL
Expand Down
2 changes: 1 addition & 1 deletion Tests/ZIPFoundationTests/ZIPFoundationWritingTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ extension ZIPFoundationTests {
}
defer { try? FileManager.default.removeItem(at: tempDir) }

waitForExpectations(timeout: 30.0)
wait(for: [unmountVolumeExpectation, createVolumeExpectation])
#endif
}
}
Loading