2014-12-08 05:09:33 +08:00
|
|
|
|
2016-07-28 23:37:32 +08:00
|
|
|
GzipSwift
|
2014-12-08 05:09:33 +08:00
|
|
|
========================
|
|
|
|
|
2017-02-16 01:44:03 +08:00
|
|
|
[![platform](https://img.shields.io/badge/platform-macOS%20|%20iOS%20|%20watchOS%20|%20tvOS%20|%20Linux-blue.svg)]()
|
2019-11-17 21:08:15 +08:00
|
|
|
[![CI Status](https://github.com/1024jp/GzipSwift/workflows/CI/badge.svg)](https://github.com/1024jp/GzipSwift/actions)
|
2019-11-21 09:30:40 +08:00
|
|
|
[![Carthage-compatible](https://img.shields.io/badge/Carthage-✔-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage)
|
|
|
|
[![SwiftPM-compatible](https://img.shields.io/badge/SwiftPM-✔-4BC51D.svg?style=flat)](https://swift.org/package-manager/)
|
|
|
|
[![CocoaPods-compatible](http://img.shields.io/cocoapods/v/GzipSwift.svg?style=flat)](https://cocoapods.org/pods/GzipSwift)
|
2015-05-12 11:13:49 +08:00
|
|
|
|
2016-08-13 13:28:55 +08:00
|
|
|
__GzipSwift__ is a framework with an extension of Data written in Swift. It enables compress/decompress gzip using zlib.
|
2014-12-08 05:09:33 +08:00
|
|
|
|
2022-03-26 22:09:16 +08:00
|
|
|
- __Requirements__: OS X 10.9 / iOS 12 / watchOS 2 / tvOS 12 or later
|
|
|
|
- __Swift version__: Swift 5.6
|
2014-12-08 05:09:33 +08:00
|
|
|
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
```swift
|
2016-07-28 20:26:03 +08:00
|
|
|
import Gzip
|
|
|
|
|
2014-12-08 05:09:33 +08:00
|
|
|
// gzip
|
2016-07-17 23:55:34 +08:00
|
|
|
let compressedData: Data = try! data.gzipped()
|
|
|
|
let optimizedData: Data = try! data.gzipped(level: .bestCompression)
|
2014-12-08 05:09:33 +08:00
|
|
|
|
|
|
|
// gunzip
|
2016-07-17 23:55:34 +08:00
|
|
|
let decompressedData: Data
|
2017-07-16 14:25:39 +08:00
|
|
|
if data.isGzipped {
|
2016-07-17 23:55:34 +08:00
|
|
|
decompressedData = try! data.gunzipped()
|
|
|
|
} else {
|
|
|
|
decompressedData = data
|
|
|
|
}
|
2014-12-08 05:09:33 +08:00
|
|
|
```
|
|
|
|
|
|
|
|
|
|
|
|
## Installation
|
|
|
|
|
2019-11-17 16:10:21 +08:00
|
|
|
### Swift Package Manager
|
2017-02-16 01:44:03 +08:00
|
|
|
|
2019-11-21 09:30:40 +08:00
|
|
|
GzipSwift is SwiftPM-compatible. To install, add this package to your `Package.swift` or your Xcode project.
|
2019-11-17 16:10:21 +08:00
|
|
|
|
|
|
|
#### For Linux
|
|
|
|
|
|
|
|
1. Install zlib if you haven't installed yet:
|
|
|
|
|
|
|
|
```bash
|
|
|
|
$ 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`
|
2014-12-08 05:09:33 +08:00
|
|
|
|
2016-11-30 02:27:47 +08:00
|
|
|
### Carthage
|
2019-11-21 09:30:40 +08:00
|
|
|
GzipSwift is [Carthage](https://github.com/Carthage/Carthage)-compatible. To install, add the following line to your `Cartfile`:
|
2016-08-18 00:16:39 +08:00
|
|
|
|
|
|
|
```ruby
|
2017-09-17 17:22:19 +08:00
|
|
|
github "1024jp/GzipSwift"
|
2016-08-18 00:16:39 +08:00
|
|
|
```
|
2015-09-03 16:07:49 +08:00
|
|
|
|
2016-11-30 02:27:47 +08:00
|
|
|
### CocoaPods
|
2019-11-17 16:10:21 +08:00
|
|
|
GzipSwift is available through [CocoaPods](http://cocoapods.org). To install, add the following line to your `Podfile`:
|
2015-09-03 16:07:49 +08:00
|
|
|
|
|
|
|
```ruby
|
2017-09-17 17:22:19 +08:00
|
|
|
pod 'GzipSwift'
|
2015-09-03 16:07:49 +08:00
|
|
|
```
|
|
|
|
|
2019-11-17 16:10:21 +08:00
|
|
|
### Manual Installation
|
2016-09-24 12:21:43 +08:00
|
|
|
|
2019-11-17 16:10:21 +08:00
|
|
|
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.
|
2016-09-24 12:21:43 +08:00
|
|
|
|
2014-12-08 05:09:33 +08:00
|
|
|
|
2017-02-16 01:44:03 +08:00
|
|
|
## License
|
2014-12-08 05:09:33 +08:00
|
|
|
|
2022-03-26 22:09:16 +08:00
|
|
|
© 2014-2022 1024jp
|
2014-12-08 05:09:33 +08:00
|
|
|
|
2017-02-16 01:44:03 +08:00
|
|
|
GzipSwift is distributed under the terms of the __MIT License__. See [LICENSE](LICENSE) for details.
|