/Zip

Swift framework for zipping and unzipping files. Support Swift Package Manager.

Primary LanguageMakefile

Zip

Swift framework for zipping and unzipping files. Support Swift Package Manager.

import PackageDescription

let package = Package(
    name: "Demo",
    dependencies: [
        .package(url: "https://github.com/mzying2013/Zip.git", from: "2.0.0")
    ],
    targets: [
        .target(name: "App", dependencies: ["Zip"]),
        .testTarget(name: "AppTests", dependencies: ["App"])
    ]
)

Note

If you want to generate and run an xcode project, you have to add libz.tbd in target of minizip.

Quick functions

The easiest way to use Zip is through quick functions. Both take local file paths as NSURLs, throw if an error is encountered and return an NSURL to the destination if successful.

do {
    let filePath = Bundle.main.url(forResource: "file", withExtension: "zip")!
    let unzipDirectory = try Zip.quickUnzipFile(filePath) // Unzip
    let zipFilePath = try Zip.quickZipFiles([filePath], fileName: "archive") // Zip
}
catch {
  print("Something went wrong")
}