Giter VIP home page Giter VIP logo

gzipswift's Introduction

GzipSwift

Swift ![platform](https://img.shields.io/badge/platform-macOS | iOS | watchOS | tvOS | Linux-blue.svg) Carthage compatible CocoaPods compatible Build Status codecov.io License

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

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
}

// check data is gzipped
print(compressedData.isGzipped)

Installation

  1. Build Gzip framework.
  2. In Build Phases, add Gzip.framework library to your project.
  3. import Gzip in your Swift file.
  4. Use in your code.

Build via Carthage

GzipSwift is Carthage compatible. You can easily build GzipSwift adding the following line to your Cartfile.

github "1024jp/GzipSwift"

Build via CocoaPods

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

pod "GzipSwift"

For Linux platform with swift package manager

  1. First you need to install zlib if you haven't installed yet:

    $ apt-get install zlib-dev
  2. add this packge 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

Lisence

© 2014-2016 1024jp

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

gzipswift's People

Contributors

1024jp avatar michael-yuji avatar

Watchers

James Cloos avatar Warner Zee avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.