Skip to content

Commit a7b3309

Browse files
committed
Support for Swift 5.0
1 parent 0c23254 commit a7b3309

File tree

3 files changed

+32
-15
lines changed

3 files changed

+32
-15
lines changed

DataCompression.podspec

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
Pod::Spec.new do |s|
22
s.name = "DataCompression"
3-
s.version = "3.1.0"
3+
s.version = "3.2.0"
44
s.summary = "Swift libcompression wrapper as an extension for the Data type (GZIP, ZLIB, LZFSE, LZMA, LZ4, deflate, RFC-1950, RFC-1951, RFC-1952)"
55
s.authors = { "Markus Wanke" => "mw99@users.noreply.github.com" }
66
s.homepage = "https://github.com/mw99/DataCompression"
77
s.license = { :type => 'Apache 2.0', :file => 'LICENSE' }
88
s.source = { :git => "https://github.com/mw99/DataCompression.git", :tag => s.version }
99

10-
s.swift_version = '4.2'
10+
s.swift_version = '5.0'
1111

1212
s.ios.deployment_target = '9.0'
1313
s.osx.deployment_target = '10.11'
1414
s.tvos.deployment_target = '9.0'
1515
s.watchos.deployment_target = '2.0'
1616

17-
s.source_files = 'Sources/*.swift'
17+
s.source_files = 'Sources/DataCompression/*.swift'
1818
s.requires_arc = true
1919
end

Package.swift

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
1+
// swift-tools-version:4.0
2+
13
import PackageDescription
24

3-
let package = Package(name: "DataCompression")
5+
let package = Package(
6+
name: "DataCompression",
7+
products: [
8+
.library(
9+
name: "DataCompression",
10+
targets: ["DataCompression"]),
11+
],
12+
targets: [
13+
.target(
14+
name: "DataCompression",
15+
dependencies: []),
16+
.testTarget(
17+
name: "DataCompressionTests",
18+
dependencies: ["DataCompression"]),
19+
]
20+
)

Sources/DataCompression.swift Sources/DataCompression/DataCompression.swift

+11-11
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public extension Data
3535
/// Compresses the data.
3636
/// - parameter withAlgorithm: Compression algorithm to use. See the `CompressionAlgorithm` type
3737
/// - returns: compressed data
38-
public func compress(withAlgorithm algo: CompressionAlgorithm) -> Data?
38+
func compress(withAlgorithm algo: CompressionAlgorithm) -> Data?
3939
{
4040
return self.withUnsafeBytes { (sourcePtr: UnsafePointer<UInt8>) -> Data? in
4141
let config = (operation: COMPRESSION_STREAM_ENCODE, algorithm: algo.lowLevelType)
@@ -46,7 +46,7 @@ public extension Data
4646
/// Decompresses the data.
4747
/// - parameter withAlgorithm: Compression algorithm to use. See the `CompressionAlgorithm` type
4848
/// - returns: decompressed data
49-
public func decompress(withAlgorithm algo: CompressionAlgorithm) -> Data?
49+
func decompress(withAlgorithm algo: CompressionAlgorithm) -> Data?
5050
{
5151
return self.withUnsafeBytes { (sourcePtr: UnsafePointer<UInt8>) -> Data? in
5252
let config = (operation: COMPRESSION_STREAM_DECODE, algorithm: algo.lowLevelType)
@@ -60,7 +60,7 @@ public extension Data
6060
/// lzfse : Apples custom Lempel-Ziv style compression algorithm. Claims to compress as good as zlib but 2 to 3 times faster.
6161
/// lzma : Horribly slow. Compression as well as decompression. Compresses better than zlib though.
6262
/// lz4 : Fast, but compression rate is very bad. Apples lz4 implementation often to not compress at all.
63-
public enum CompressionAlgorithm
63+
enum CompressionAlgorithm
6464
{
6565
case zlib
6666
case lzfse
@@ -71,7 +71,7 @@ public extension Data
7171
/// Compresses the data using the zlib deflate algorithm.
7272
/// - returns: raw deflated data according to [RFC-1951](https://tools.ietf.org/html/rfc1951).
7373
/// - note: Fixed at compression level 5 (best trade off between speed and time)
74-
public func deflate() -> Data?
74+
func deflate() -> Data?
7575
{
7676
return self.withUnsafeBytes { (sourcePtr: UnsafePointer<UInt8>) -> Data? in
7777
let config = (operation: COMPRESSION_STREAM_ENCODE, algorithm: COMPRESSION_ZLIB)
@@ -82,7 +82,7 @@ public extension Data
8282
/// Decompresses the data using the zlib deflate algorithm. Self is expected to be a raw deflate
8383
/// stream according to [RFC-1951](https://tools.ietf.org/html/rfc1951).
8484
/// - returns: uncompressed data
85-
public func inflate() -> Data?
85+
func inflate() -> Data?
8686
{
8787
return self.withUnsafeBytes { (sourcePtr: UnsafePointer<UInt8>) -> Data? in
8888
let config = (operation: COMPRESSION_STREAM_DECODE, algorithm: COMPRESSION_ZLIB)
@@ -93,7 +93,7 @@ public extension Data
9393
/// Compresses the data using the deflate algorithm and makes it comply to the zlib format.
9494
/// - returns: deflated data in zlib format [RFC-1950](https://tools.ietf.org/html/rfc1950)
9595
/// - note: Fixed at compression level 5 (best trade off between speed and time)
96-
public func zip() -> Data?
96+
func zip() -> Data?
9797
{
9898
let header = Data(bytes: [0x78, 0x5e])
9999

@@ -113,7 +113,7 @@ public extension Data
113113
/// Decompresses the data using the zlib deflate algorithm. Self is expected to be a zlib deflate
114114
/// stream according to [RFC-1950](https://tools.ietf.org/html/rfc1950).
115115
/// - returns: uncompressed data
116-
public func unzip(skipCheckSumValidation: Bool = true) -> Data?
116+
func unzip(skipCheckSumValidation: Bool = true) -> Data?
117117
{
118118
// 2 byte header + 4 byte adler32 checksum
119119
let overhead = 6
@@ -151,7 +151,7 @@ public extension Data
151151
/// Compresses the data using the deflate algorithm and makes it comply to the gzip stream format.
152152
/// - returns: deflated data in gzip format [RFC-1952](https://tools.ietf.org/html/rfc1952)
153153
/// - note: Fixed at compression level 5 (best trade off between speed and time)
154-
public func gzip() -> Data?
154+
func gzip() -> Data?
155155
{
156156
var header = Data(bytes: [0x1f, 0x8b, 0x08, 0x00]) // magic, magic, deflate, noflags
157157

@@ -181,7 +181,7 @@ public extension Data
181181
/// Decompresses the data using the gzip deflate algorithm. Self is expected to be a gzip deflate
182182
/// stream according to [RFC-1952](https://tools.ietf.org/html/rfc1952).
183183
/// - returns: uncompressed data
184-
public func gunzip() -> Data?
184+
func gunzip() -> Data?
185185
{
186186
// 10 byte header + data + 8 byte footer. See https://tools.ietf.org/html/rfc1952#section-2
187187
let overhead = 10 + 8
@@ -247,7 +247,7 @@ public extension Data
247247

248248
/// Calculate the Adler32 checksum of the data.
249249
/// - returns: Adler32 checksum type. Can still be further advanced.
250-
public func adler32() -> Adler32
250+
func adler32() -> Adler32
251251
{
252252
var res = Adler32()
253253
res.advance(withChunk: self)
@@ -256,7 +256,7 @@ public extension Data
256256

257257
/// Calculate the Crc32 checksum of the data.
258258
/// - returns: Crc32 checksum type. Can still be further advanced.
259-
public func crc32() -> Crc32
259+
func crc32() -> Crc32
260260
{
261261
var res = Crc32()
262262
res.advance(withChunk: self)

0 commit comments

Comments
 (0)