Swiftpack.co - Package - marmelroy/Zip
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.

Zip - Zip and unzip files in Swift

Build Status Version Carthage compatible SPM supported


A Swift framework for zipping and unzipping files. Simple and quick to use. Built on top of minizip.


Import Zip at the top of the Swift file.

import Zip

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")

Advanced Zip

For more advanced usage, Zip has functions that let you set custom destination paths, work with password protected zips and use a progress handling closure. These functions throw if there is an error but don't return.

do {
    let filePath = Bundle.main.url(forResource: "file", withExtension: "zip")!
    let documentsDirectory = FileManager.default.urls(for:.documentDirectory, in: .userDomainMask)[0]
    try Zip.unzipFile(filePath, destination: documentsDirectory, overwrite: true, password: "password", progress: { (progress) -> () in
    }) // Unzip

    let zipFilePath = documentsFolder.appendingPathComponent("archive.zip")
    try Zip.zipFiles([filePath], zipFilePath: zipFilePath, password: "password", progress: { (progress) -> () in
    }) //Zip

catch {
  print("Something went wrong")

Custom File Extensions

Zip supports '.zip' and '.cbz' files out of the box. To support additional zip-derivative file extensions:


[Preferred] Setting up with Swift Package Manager

To use Zip with Swift Package Manager, add it to your package's dependencies:

.package(url: "https://github.com/marmelroy/Zip.git", .upToNextMinor(from: "2.1"))

Setting up with CocoaPods

source 'https://github.com/CocoaPods/Specs.git'
pod 'Zip', '~> 2.1'

Setting up with Carthage

To integrate Zip into your Xcode project using Carthage, specify it in your Cartfile:

github "marmelroy/Zip" ~> 2.1


Stars: 1925


Zip 2.1.1 - 2020-09-26T13:43:42

  • Fixed broken Cocoapods podspec

Zip 2.1.0 - 2020-09-24T20:51:47

  • Updates for Xcode 12 support

2.0.0 - Release - 2020-05-04T07:44:15

Zip 1.1.0 - 2017-11-26T17:38:12

  • Added includeRootDirectory logic (thanks @peterboni)
  • Fixed warnings and build issues (thanks @peterboni, @radianttap, @pgodino)

Zip 1.0.0 - 2017-09-21T05:45:38

  • Swift 4 support (thanks @jabez1314, @dimakomar)
  • Unzip file handler support (thanks @piemonte)
  • Add fwrite() and uncompressed_size validation (thanks @bricklife)

Zip 0.8.0 - 2017-09-20T12:35:39

  • Last Swift 3 release

Zip 0.6.0 - 2016-09-19T18:37:28

  • No more submodules. Relevant Minizip files now checked in. This means the return of Carthage support.
  • Zip is now available for extensions (thanks @basememara).
  • Documentation updates.

Zip 0.5 - 2016-09-18T10:20:46

  • Official Swift 3 release

Zip 0.4.3 - 2016-06-17T07:40:00

  • Memory leak fix (thanks @pilot34)

Zip 0.4.2 - 2016-05-12T21:04:56

  • Fixing Carthage tvOS issues.

Zip 0.4.1 - 2016-05-12T20:46:39

  • Handle any file extension (thanks @timbjarengren).
  • tvOS target fix.

Zip 0.4.0 - 2016-05-10T22:00:58

Adding tvOS target

Release 0.3.3 - 2016-03-17T07:28:16

  • Subdirectory bug fix by @gwjakewelton

Release 0.3.0 - 2016-03-07T13:10:51

  • Adding OSX support.

Release 0.2.0 - 2016-01-27T05:44:51

  • Added ability to zip folder paths and their contents.
  • Support for iOS8, tvOS and watchOS.
  • Added Swift Package Manager.

Release 0.1.4 - 2016-01-19T20:03:48

Improved syntax and better documentation.

Release 0.1.2 - 2016-01-17T19:09:43

First release for Zip - a Swift framework for zipping and unzipping files.

Features include:

  • Quick zip and unzip.
  • Password support.
  • Progress handler.