Swift framework that enables gzip/gunzip Data using zlib


platform CI Status Carthage-compatible SwiftPM-compatible CocoaPods-compatible

GzipSwift is a framework with an extension of Data written in Swift. It enables compress/decompress gzip using zlib.

  • Requirements: OS X 10.9 / iOS 12 / watchOS 2 / tvOS 12 or later
  • Swift version: Swift 5.6


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


Swift Package Manager

GzipSwift is SwiftPM-compatible. To install, add this package to your Package.swift or your Xcode project.

For Linux

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

    $ apt-get install zlib-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


GzipSwift is Carthage-compatible. To install, add the following line to your Cartfile:

github "1024jp/GzipSwift"


GzipSwift is available through CocoaPods. To install, add the following line to your Podfile:

pod 'GzipSwift'

Manual Installation

  1. Open Gzip.xcodeproj on Xcode and build Gzip framework for your target platform.
  2. Append the built Gzip.framework to your project.
  3. Go to General pane of the application target in your project. Add Gzip.framework to the Embedded Binaries section.


© 2014-2022 1024jp

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


  • Swift Tools 5.0.0
View More Packages from this Author


  • None
Last updated: Sun Mar 26 2023 00:54:31 GMT-0500 (GMT-05:00)