A Swift package that offers simple compression (deflate) and decompression (inflate) functionalities built on top of zlib.
- Compression using
deflate
- Decompression using
inflate
- Customizable compression levels
- Seamless integration with
Data
type in Swift
Add the following line to the dependencies in your Package.swift
file:
.package(url: "https://github.com/stremovskyy/SwiftyDeflate.git", from: "1.0.0")
do {
let originalData: Data = ... // Your data
let compressedData = try originalData.deflateCompress()
// Use compressedData
} catch {
print("Error during compression: \(error.localizedDescription)")
}
do {
let compressedData: Data = ... // Your compressed data
let decompressedData = try compressedData.deflateDecompress()
// Use decompressedData
} catch {
print("Error during decompression: \(error.localizedDescription)")
}
- Swift 5.3+
- macOS, iOS, watchOS, tvOS
Contributions are very welcome! Please submit a pull request or create an issue to share your improvements or report bugs.
SwiftyDeflate is released under the MIT License. See LICENSE
for details.