SwiftZipArchive is a Swift-first ZIP library for Apple platforms.
It is a rewrite of SSZipArchive's API surface in Swift, backed by minizip-ng C sources for ZIP format compatibility and encryption support.
- Create ZIP archives from files and directories
- Extract ZIP archives with overwrite control
- Password validation and password-protected extraction
- AES and PKWARE encryption support
- Nested ZIP extraction support
- Symlink-safe extraction controls (
symlinksValidWithin) - Delegate, progress, and completion callbacks
- Incremental ZIP writer API (
open,write...,close)
- Swift 5.9+
- Xcode 15+
- iOS 15.5+
- macOS 10.15+
- tvOS 15.4+
- watchOS 8.4+
- visionOS 1.0+
.package(url: "https://github.com/matt-minev/SwiftZipArchive.git", from: "1.0.0")Then add the product:
.product(name: "SwiftZipArchive", package: "SwiftZipArchive")import SwiftZipArchive
let created = SwiftZipArchive.createZipFile(
atPath: "/tmp/example.zip",
withContentsOfDirectory: "/tmp/input"
)
let extracted = SwiftZipArchive.unzipFile(
atPath: "/tmp/example.zip",
toDestination: "/tmp/output"
)- Primary type:
SwiftZipArchive - Primary delegate:
SwiftZipArchiveDelegate - Primary error:
SwiftZipArchiveError - NSError bridge domain:
SwiftZipArchiveErrorDomain
This repository includes runnable SwiftPM examples:
Examples/CreateArchive: create an archive from a directoryExamples/ExtractArchive: extract an archive with optional password
Run with:
swift run SwiftZipArchiveCreateExample <source-directory> <output-zip>
swift run SwiftZipArchiveExtractExample <zip-path> <output-directory> [password]swift testTests include parity-critical scenarios ported from the original Objective-C suite:
- Basic create/extract round trip
- Password-protected and AES extraction
- Password validation APIs
- Unicode filenames
- Path traversal sanitization
- Symlink safety controls
- Nested ZIP extraction
- Delegate/progress callback behavior
SSZipArchiveis renamed toSwiftZipArchiveSSZipArchiveDelegateis renamed toSwiftZipArchiveDelegate- Swift error throwing is used where Objective-C APIs previously used
NSError** - Objective-C compatibility aliases are intentionally removed in this release
SwiftZipArchive builds directly on the work of the original ZipArchive / SSZipArchive maintainers and contributors:
- Original project: ZipArchive/ZipArchive
- Original SSZipArchive naming and early implementation by Sam Soffes
- Ongoing ZIP engine foundations from minizip-ng by nmoinvaz
- Thanks to all contributors to both the original project and minizip-ng
- SwiftZipArchive project code is licensed under MIT (
LICENSE.txt) - Bundled
minizip-ngsources remain under the Zlib license (CMinizip/minizip/LICENSE)