Zip is a lightweight cross-platform Swift package for working with Zip archives. It's built on top of Miniz and includes its entire implementation, so no external dependencies are required.
Zip runs on Linux, Windows and all Apple platforms.
- Add and read files from ZIP archives.
- Support for both file-based and in-memory archives.
- Iterative reading of files in chunk.
- Configurable compression levels.
- Minimalistic and modern Swift API.
Add the package to your project using Swift Package Manager. In your Package.swift file:
dependencies:[.package(url:"https://github.com/tomasf/Zip.git", from:"2.0.0")]letarchive=ZipArchive()try archive.addFile(at:"content.json", data: jsonData)letzipData=try archive.finalize()letnewArchive=tryZipArchive(data: zipData)letdata=try archive.fileContents(at:"hello.txt")iflet text =String(data: data, encoding:.utf8){print("Hello.txt contains: \(text)")}letarchive=tryZipArchive(url: archiveURL)try archive.addFile(at:"hello.txt", data:Data("Hello, Zip!".utf8))try archive.finalize() // Writes Zip data to diskContributions are welcome! If you have ideas, suggestions, or bug reports, feel free to open an issue on GitHub. Pull requests are also appreciated.
This project is licensed under the MIT License. See the LICENSE file for details.