All Projects → SwiftZip → SwiftZip

SwiftZip / SwiftZip

Licence: MIT license
Swift wrapper for libzip — library for reading, creating, and modifying zip archives.

Programming Languages

swift
15916 projects
c
50402 projects - #5 most used programming language
shell
77523 projects

Projects that are alternatives of or similar to SwiftZip

swift-watch
Watches over your Swift project's source
Stars: ✭ 43 (-2.27%)
Mutual labels:  swift-package-manager, spm
uncompress.js
Uncompress ZIP, RAR, and TAR files with pure JavaScript
Stars: ✭ 79 (+79.55%)
Mutual labels:  zip, unzip
cordova-plugin-zeep
Zip compression/decompression for the cordova/phonegap platform
Stars: ✭ 27 (-38.64%)
Mutual labels:  zip, unzip
Aksidemenu
Beautiful iOS side menu library with parallax effect. Written in Swift
Stars: ✭ 216 (+390.91%)
Mutual labels:  swift-package-manager, spm
SwiftDown
📦 A themable markdown editor component for your SwiftUI apps.
Stars: ✭ 203 (+361.36%)
Mutual labels:  swift-package-manager, spm
ftpConnect
A simple and robust dart FTP Client Library to interact with FTP Servers with possibility of zip and unzip files.
Stars: ✭ 43 (-2.27%)
Mutual labels:  zip, unzip
aspZip
A classic ASP zip and unzip utility class that uses the native zip support from Windows (XP and above) - no components needed
Stars: ✭ 24 (-45.45%)
Mutual labels:  zip, unzip
Sketchkit
A lightweight auto-layout DSL library for iOS & tvOS.
Stars: ✭ 40 (-9.09%)
Mutual labels:  swift-package-manager, spm
CSV
A simple CSV file parser and serializer
Stars: ✭ 31 (-29.55%)
Mutual labels:  swift-package-manager, spm
Zip
Swift framework for zipping and unzipping files.
Stars: ✭ 2,120 (+4718.18%)
Mutual labels:  zip, unzip
SupportEmail
Pre-populates emails with support information in iOS/iPadOS apps
Stars: ✭ 20 (-54.55%)
Mutual labels:  swift-package-manager, spm
extensions-kit
📦 Collection of Swift+Apple Frameworks extensions for speeding up software development [iOS & iPadOS].
Stars: ✭ 71 (+61.36%)
Mutual labels:  swift-package-manager, spm
Flexcolorpicker
Modern color picker library written in Swift 5 that can be easily extended and customized. It aims to provide great UX and performance with stable, quality code.
Stars: ✭ 164 (+272.73%)
Mutual labels:  swift-package-manager, spm
Match3Kit
Library for simple Match3 games.
Stars: ✭ 38 (-13.64%)
Mutual labels:  swift-package-manager, spm
Expandable Collection View Kit
🗂 Expandable, hierarchical, flexible, declarative UICollectionView with diffable data sources & SwiftUI-like tree items builder [Swift 5.1, iOS & iPadOS 13].
Stars: ✭ 69 (+56.82%)
Mutual labels:  swift-package-manager, spm
unzip
Tiny unzip helper class for .NET 3.5 Client Profile and Mono 2.10, written in pure C#.
Stars: ✭ 25 (-43.18%)
Mutual labels:  zip, unzip
xcframework-maker
macOS utility for converting fat-frameworks to SPM-compatible XCFramework with arm64-simulator support
Stars: ✭ 239 (+443.18%)
Mutual labels:  swift-package-manager, spm
Hippolyte
HTTP Stubbing in Swift
Stars: ✭ 109 (+147.73%)
Mutual labels:  swift-package-manager, spm
cross-unzip
Cross-platform 'native' unzip in Node.js
Stars: ✭ 17 (-61.36%)
Mutual labels:  zip, unzip
Zip.js
JavaScript library to zip and unzip files in the browser and Deno
Stars: ✭ 2,444 (+5454.55%)
Mutual labels:  zip, unzip

Overview

macOS iOS Linux

SwiftZip is a Swift wrapper for libzip providing an API to read, create and modify zip archives. Files can be added from data buffers, files, or compressed data copied directly from other zip archives. Changes made without closing the archive can be reverted.

Note: SwiftZip is currently under development and API may change slightly as the project evolves.

Getting Started

Quick Instructions

Opening and inspecting an archive:

do {
    // Open an archive for reading
    let archive = try ZipArchive(url: archiveUrl)

    // Enumerate entries in the archive
    for entry in archive.entries {
        // Get basic entry information
        let name = try entry.getName()
        let size = try entry.stat().size
        print("\(name) -> \(size as Any)")

        // Read entry contents into a `Data` instance
        let data = try entry.data()
        print(data)
    }
} catch {
    // Handle possible errors
    print("\(error)")
}

Creating an archive:

do {
    // Open an archive for writing, overwriting any existing file
    let archive = try ZipMutableArchive(url: archiveUrl, flags: [.create, .truncate])

    // Load the test data
    let data = try Data(contentsOf: dataUrl)

    // Create a data source and add it to the archive
    let source = try ZipSource(data: data)
    try archive.addFile(name: "filename.dat", source: source)

    // Commit changes and close the archive
    // Alternatively call `discard` to rollback any changes
    try archive.close()
} catch {
    // Handle possible errors
    print("\(error)")
}

Getting More Help

Auto-generated documentation based on libzip manual is available at https://swiftzip.github.io/.

SwiftZip is designed to be a thin wrapper aroung libzip. Please refer to the original libzip documentation to get more details on the underlying implementation: https://libzip.org/documentation/.

Current libzip API mapping and coverage is available at API.md

Installation

Swift Package Manager

To depend on the SwiftZip package, you need to declare your dependency in your Package.swift file:

dependencies: [
    .package(url: "https://github.com/SwiftZip/SwiftZip.git", .branch("master")),
    // ...
]

and add "SwiftZip" to your application/library target dependencies, e.g. like this:

.target(name: "BestExampleApp", dependencies: [
    "SwiftZip",
    // ...
])

Using SwiftZip on Linux

SwiftZip requires BZip2 and OpenSSL development packages to be installed when building on Linux. You can install the required dependencies using apt on Ubuntu:

apt-get install libbz2-dev
apt-get install libssl-dev

SwiftZip Project

SwiftZip in currently under development. Please open an issue or submit a pull request in case you find any issues or have any improvement ideas.

Project Goals

  • the primary goal of the SwiftZip project is to provide first-class Swift bindings for libzip on all supported platforms
  • the initial target is the iOS platform without any external dependencies, macOS and Linux targets will be added later

Design Considerations

  • libzip must be included "as is" without any modifications to allow easy drop-in updates
  • the library should be entirely opaque providing a native Swift interface for all libzip functionality
  • the binding layer should propagate all underlying errors so client code can properly handle them

Project Structure

  • all libzip-related files are located under the Sources/zip directory and exposed as zip package
  • Sources/zip/libzip is a submodule referencing relevant libzip source code
  • Sources/zip/libzip-patches folder contains patches to be applied to the libzip header files, so they are compatible with the Swift package manager
  • Sources/zip/include contains public headers for the libzip as required by the Swift package manager
  • Sources/zip/include-private contains patched private headers to build libzip
  • Swift wrappers are located under the Sources/SwiftZip directory and exposed as SwiftZip package

Updating libzip

The SwiftZip wrapper is designed to make libzip updates as easy as possible. To update the underlying library, use the ./Tools/libzip-update.sh script to pull the latest version in the Sources/zip/libzip submodule and update public headers.

TODO/Roadmap:

  • provide an initial set of wrappers for archive operations
  • adapt libzip docs and convert them to code comments
  • provide Swift protocol-based wrapper for custom sources API
  • add Linux build support
  • cover core functionality with tests based on libzip test suite

License

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].