GzipSwift

7.0.0

Swift package that enables gzip/gunzip Data using zlib
1024jp/GzipSwift

What's New

7.0.0

2026-05-05T13:54:44Z

Breaking Changes

  • Update Swift version to 6.3.
  • Compressing an empty Data now produces a valid empty gzip stream instead of returning an empty Data.
  • Decompressing an empty Data now throws GzipError instead of returning an empty Data.

New

  • Support typed throw.
  • Conform GzipError, GzipError.Kind, and CompressionLevel to Hashable.
  • Conform CompressionLevel to Comparable.

Changes

  • Make maxWindowBits a module-level constant.
  • Show zlib error messages when GzipError is handled as Error.
  • Improve the error message when decompression cannot make progress.
  • Find zlib headers installed outside /usr/include on Linux, such as Linuxbrew.
  • Improve memory allocation when decompressing small inputs.

Fixes

  • Fix accessing types with the Gzip module prefix, such as Gzip.CompressionLevel.
  • Avoid a crash when compressing or decompressing data larger than 4 GiB; compression now throws an error instead.

Full Changelog: 6.1.0...7.0.0

GzipSwift

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.

platform

Usage

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
}

Installation

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(7, 0, 0)),
],

For Linux

  1. Install zlib if you haven't installed yet:

    $ apt-get install zlib1g-dev
  2. Add this package to your package.swift.

  3. If Swift build failed with a linker error:

    • check if libz.so is in your /usr/local/lib
      • if no, reinstall zlib as step (1)
      • if yes, link the library manually by passing '-Xlinker -L/usr/local/lib' with swift build

License

© 2014-2026 1024jp

GzipSwift is distributed under the terms of the MIT License. See LICENSE for details.

Description

  • Swift Tools 6.3.0
View More Packages from this Author

Dependencies

  • None
Last updated: Sat May 23 2026 07:35:32 GMT-0900 (Hawaii-Aleutian Daylight Time)