GzipSwift is a framework with an extension of Data written in Swift. It enables compress/decompress gzip using zlib.
GzipSwift requires no privacy manifests since it does not access to any privacy information.
import Gzip
// gzip
let compressedData: Data = try! data.gzipped()
let optimizedData: Data = try! data.gzipped(level: .bestCompression)
// gunzip
let decompressedData: Data
if data.isGzipped {
decompressedData = try! data.gunzipped()
} else {
decompressedData = data
}
GzipSwift is SwiftPM-compatible. To install, add this package to your Package.swift
or your Xcode project.
dependencies: [
.package(name: "Gzip", url: "https://github.com/1024jp/GzipSwift", from: Version(6, 0, 0)),
],
Install zlib if you haven't installed yet:
$ apt-get install zlib-dev
swift build
© 2014-2024 1024jp
GzipSwift is distributed under the terms of the MIT License. See LICENSE for details.