![platform](https://img.shields.io/badge/platform-macOS | iOS | watchOS | tvOS | Linux-blue.svg)
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 8 / watchOS 2 / tvOS 9 or later
- Swift version: Swift 3.0.1
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
}
// check data is gzipped
print(compressedData.isGzipped)
- Build Gzip framework.
- In Build Phases, add
Gzip.framework
library to your project. import Gzip
in your Swift file.- Use in your code.
GzipSwift is Carthage compatible. You can easily build GzipSwift adding the following line to your Cartfile.
github "1024jp/GzipSwift"
GzipSwift is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod "GzipSwift"
-
First you need to install zlib if you haven't installed yet:
$ apt-get install zlib-dev
-
add this packge to your package.swift
-
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
© 2014-2016 1024jp
GzipSwift is distributed under the terms of the MIT License. See LISENCE for details.