Giter VIP home page Giter VIP logo

zip's Introduction

Zip - Zip and unzip files in Swift

Build Status Version Carthage compatible SPM supported

Zip

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

Usage

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
        print(progress)
    }) // Unzip

    let zipFilePath = documentsFolder.appendingPathComponent("archive.zip")
    try Zip.zipFiles([filePath], zipFilePath: zipFilePath, password: "password", progress: { (progress) -> () in
        print(progress)
    }) //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:

Zip.addCustomFileExtension("file-extension-here")

[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

zip's People

Contributors

avdlee avatar buscarini avatar chris-guidry avatar coeur avatar ffried avatar gwjakewelton avatar huguesbr avatar jwelton avatar macness-pavelh avatar marmelroy avatar marmelroyspotify avatar mflint avatar mingchen avatar mostafaberg avatar nighthawk avatar peterboni avatar piemonte avatar pilot34 avatar radianttap avatar rohan-elear avatar ryanmeasel avatar simonseyer avatar stoqn4opm avatar tbergmen avatar timbjarengren avatar workshed avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zip's Issues

Progress kind

Hi @marmelroy,
is it possibile to add decompressing kind in the implicit Progress?

progressTracker.setUserInfoObject(Progress.FileOperationKind.decompressingAfterDownloading, forKey: .fileOperationKindKey)

No such module 'minizip' with Swift 2.3 and CocoaPods

Hi,
have an issue integrating it in the Swift 2.3 project, receive No such module 'minizip'.
The interesting thing that minizip is not getting cloned by CocoaPods, submodule files just don't exist in Pods directory. Tried with CocoaPods version 1.0 and 1.1.0.beta.1

About errors

If the specified folder, which should be zipped, does not exist, following error is thrown:

Error Domain=Zip.ZipError Code=2 "(null)"

This description is not very helpful. However: if the specified folder, where the zipped archive should be stored, does not exist, no error occurs.

Unzipping zip archives that were created on Windows with 7Zip

Dear Mr. Roy Marmelstein

This is for sure not a bug. But I have not found a solution for the following problem. Maybe you can give me a quick advice.

If I create a zip archive with the OS X default compression feature that's integrated in Finder and extract this archive again with Zip.unzip then unzipping works.

If I create an archive on Windows with 7Zip then Zip.unzip throws an exception 'Error.UnzipFail' in file 'zip.swift' at line 92 because 'unzOpenCurrentFile' returned with -103 (UNZ_BADZIPFILE).

I have tryed all zip compression algorithms that are offered by 7Zip: Deflate, Deflate64, BZip2, LZMA and PPMd.

Can you tell me the algorithm to use for compression, to successfully extract archives with your library on iOS?

Yours sincerely
Tobias Miller

No Mac platform support

Hi, I am using Carthage and I unfortunately see no Zip.framework for Mac. I am curious if this is intentional or why there is no scheme for OS X. Would be really useful. Thanks.

*** Skipped building Zip due to the error:
Dependency "Zip" has no shared framework schemes for any of the platforms: Mac

If you believe this to be an error, please file an issue with the maintainers at https://github.com/marmelroy/Zip/issues/new

Can't compile with Swift 2.3

I have tried version 0.6.0 and version 0.4.3 with cocoapods and none will compile in Swift 2.3. 0.6.0 has way more error and seems to be the Swift 3.0 version. Which version should I use?

No such module 'minizip'

I didn't do anything... it just working fine before I went to bed, and saw this error next morning... I can't use cocoapod, I don't know what to do... just need a light unzip function...

Failed to set permissions to file

Updated my pet-project to Swift 3.0 and unzipping is totally broken. I download ZIP from my https and store into Documents. Than I unzip it in same path.

But receive error:
Failed to set permissions to file.

When I commented Set file permissions from current fileInfo block everything works well.

iOS Simulator 10. Not tested on real device.

Thanks.

Bitcode

Hi. Great work. Really easy to use. Do you have plans for bitcode support?

Password

Once zipped with password, can't unzip the file with the same password.

Progress Reporting while zipping

Original code zip.Swift line 283

var length: Int = 0  
while (feof(input) == 0) {
    length = fread(buffer, 1, chunkSize, input)
    zipWriteInFileInZip(zip, buffer, UInt32(length))
}

// Update progress handler
if let progressHandler = progress{
    progressHandler(progress: (currentPosition/totalSize))
}

Proposed

var length: Int = 0
currentPosition = 0.0
 while (feof(input) == 0) {
          length = fread(buffer, 1, chunkSize, input)
          zipWriteInFileInZip(zip, buffer, UInt32(length))
          currentPosition = currentPosition + Double.init(length)      
          // Update progress handler
          if let progressHandler = progress{
              progressHandler(progress: (currentPosition/totalSize))
          }
}

Unzip

I used Zip.zipFiles(). It works fine. But when double click the resulting zip to unzip, it creates a .zip.cpgz. Am i doing something wrong?

Error - Missing required module 'minizip'

This occurs when the Zip code files are not present. We use carthage to check out and build dependencies, but we don't commit the code / project files into our repo, just the built frameworks. When another dev checks out the project, they get this error. The built framework should be independent of the project / code files.

Can't unzip on real phone

It works well on simulator, but can't work on real device.
I tried to unzip a file to Documents directory, and got error ("Zip.ZipError" Error 0.).
Also be told: doesn't have authority to write in Documents folder. But I can do create, move or delete, just can't unzip.
Also can't google out any information about this situation, could anyone help me out of this?
Thanks a lot !

Carthage Issue

Getting this error on Carthage update on Xcode 8 - A shell task (/usr/bin/env git checkout --quiet c69afd6a7712d31287921386ddb94ca206cb727e) failed with exit code 128:
fatal: reference is not a tree: c69afd6a7712d31287921386ddb94ca206cb727e

Help in Unzip file downloaded from server

Hi i am trying to unzip a file download from server. But i couldn't do it somehow. Could anyone help me to figure out a solution for this. Here is my code:

func webLoadContent() {
// Download zip file from server

    let documentsDirectoryUrl =  FileManager.default.urls(for: .documentDirectory, in: .userDomainMask).first as! NSURL
    
    let sourceUrl = NSURL(string:"https://www.dropbox.com/s/o3uqrtxancfq1f2/test.zip?dl=0")
    
    //Get the file name and create a destination URL
    let file = sourceUrl?.lastPathComponent!
    let destinationURL = documentsDirectoryUrl.appendingPathComponent(file!)
    //Hold this file as an NSData and write it to the new location
    if let fileData = NSData(contentsOf: sourceUrl as! URL) {
        fileData.write(to: destinationURL!, atomically: false)   // true
        print("file path: \(destinationURL!.path) ")
        print("file name: \(destinationURL!.lastPathComponent)")
    }
    
    // Unzip file
    let url1 = NSURL(string: destinationURL!.path)
    do {
        let unzipURL =   try Zip.unzipFile(url1 as! URL, destination: documentsDirectoryUrl as URL, overwrite: true, password: nil, progress: { (progress) -> () in
            print(progress)
        }) // Unzip
    }catch {
        print("failed to unzip file")
    }

}

Swift 3.0

I updated to Xcode 8, swift 3, also updated Zip to 0.6.0 and now I have all these errors:
screen shot 2016-10-05 at 4 28 05 pm

Zip file created with Password on iOS can't unzip on Windows

Hi, I'm using your lib in my iOS project. My problem is the zip file that is created with password on iOS 10.0 (Both Simulator and Real iPhone) can't unzip on Windows. I've tried many unzip tools (WinRAR, 7Zip...) but all failed with a message "Wrong password". (The problem is only occurred on my password protected zip file, if password is null, it is perfectly unzipped on Windows)

Here is the zipped file https://dl.dropboxusercontent.com/u/38691130/image_pass_123.zip
Password is "123"

Thankyou so much!

Directories added twice, and empty zip created when only one subdirectory exists

I discovered a couple of errors while using the Zip library:
(I'm using Xcode 8.0 (8A218a) and the Swift 2.3 version of Zip to compile a MacOS App)

Problem 1:
When you zip a complete directory, it will include a complete extra copy of the directory in the zip file.
Example:
Directory Invoices:

  • Subdirectory 2015 (20 files)
  • Subdirectory 2016 (30 files)

When I would zip the directory Invoices it will make a zip file with the following structure:

  • Subdirectory 2015 (20 files)
  • Subdirectory 2016 (30 files)
  • Subdirectory Invoices
  • |- ----> Sub-directory 2015 (20 files)
  • |- ----> Sub-directory 2016 (30 files)

Problem 2:
When you zip a complete directory which only has one subfolder with files in it, Zip will create a 22 byte zip-file, which can't be read.
Example:
Directory Invoices:

  • Subdirectory 2015 (20 files)

Please note: the directory invoices has no other files in it, just the subdirectory 2015. If it has at least one other file or directory, it will create a zip file, but with duplicated content like explained in Problem 1..

So, something goes wrong with the directory traversal.. I checked the code in zip-utilities, but couldn't really find a problem, so I think the problem is in the lower-level c files.

It would be really great if you could fix this, because the library is very handy!

P.S. After writing this I discovered Problem 1 seems to be a duplicate of #28 . Anyway, I think it's good to have the two problems listed together in one issue, because they seem related.

Require Only App-Extension-Safe API?

Thanks for a great library!

I'd like to use this as part of an app extension. Can you enable the Require Only App-Extension-Safe API flag in the build settings. There are no compile warnings and all the unit tests still pass (see PR #32). Do you have any reservations about this?

Fix memory leak release

Hi! I see you've merged the pull request that fixes a memory leak. Can you please release a new version for it? It would be great for users of Zip to have the fix. Thanks and thanks for Zip framework!

Swift2.3 Cocoapods - minizip is missing

Migration from swift 2.2 to 2.3 with XCode 8 triggers an error on build :

no such module 'minizip'

I tried to point on specific branch without success :

pod 'Zip', '~> 0.4'
or
pod 'Zip', :git => 'https://github.com/marmelroy/Zip.git', :branch => 'swift2.3'

Missing required module 'minizip'

Hello,

i integrated your Zip Framework in my swift project with cocoapods

In my podfile:
pod 'Zip', '~> 0.4' Download the version 0.4.1

I have an error on the import Zip line in my swift file: Missing rqquired module 'minizip'
This Error is only on simulator. On device it works.

Error in Carthage

*** Fetching Zip
*** Checking out Zip at "0.6.0"
*** xcodebuild output can be found in /var/folders/gq/2y8v_smd6rxf2gsr7hbdx9w80000gn/T/carthage-xcodebuild.W6LYN2.log
*** Building scheme "Zip" in Zip.xcodeproj

The following build commands failed:
    CompileSwift normal arm64
    CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
(2 failures)

What's the connection between Zip and StoreKit?

I meet a problem really wired, the Zip module effects the In-App purchase, I don't know why.
The problem is like this:

  1. At first, everything goes fine, both Zip function and Purchase function;
  2. Next morning, Zip suddenly not available. Xcode said: "Can't find module minizip" (something like this, maybe not exactly the same);
  3. I drag unzip.h into the framework folder of the project, it works fine;
  4. Next morning, the In-App purchase not working. As went to "SKPaymentQueue.default().add(SKPayment)", it crashed and said "EXC_BAD_ACCESS, code =1 etc.";
  5. I tried a lot to find the bug, at last I found something really wired. As I print object IAP product list, the output said:

"warning: Swift error in module Zip. Debug info from this module will be unavailable in the debugger."

2016-10-08 12 02 11

  1. I just delete the unzip.h from project, everything is fine, again;
  2. Next morning, this problem occurred again. Whatever I do, it always crash when IAP triggered, and show this message:"warning: Swift error in module Zip." even I remove Zip framework!

My question is, why Zip module related StorKit module? Why these problems seems occurred randomly? Please help me, thank you!

iOS SDK Requirement

Does this library have any requirement to be using 9.2? or could it use 9.0 instead?

Execute bit is lost

Just stumbled on this as the only Swift cocoapod that works with my application. My only issue is that it strips the execute bits when it unzips. I have a zip with a .app inside. After unzipping, I get something like this guy does: http://apple.stackexchange.com/questions/181026/lsopenurlswithrole-failed-with-error-10810-cant-open-install-os-x-yosemite

When I mark everything as executable, the .app works again. That's not a very clean solution. I'm wondering if I missed something.

Below is my usage:

try Zip.unzipFile(location, destination: applicationsDirectory, overwrite: true, password: nil, progress: { (progress) -> () in
                print(progress)
                DispatchQueue.main.async {
                    self.downloadProgressBar.doubleValue = progress * 0.2 + 0.8;
                }
            }) // Unzip

Any help is much appreciated.

Unzip from NSData

Would it be possible to add a feature to uncompress an archive stored as NSData instead of a file on disk? This is useful when rather small files are downloaded and no temporary download location is needed.

Provide binary builds for Carthage

Hey

I would like to point out that it would be nice to provide the binary builds of Zip framework along with the releases. This way the framework users would not have to compile the framework each time they do the carthage bootstrap.
Reference: Carthage manual

With kind regards, Mike.

Zip 0.5 pod reference fail

-> Zip (0.4.3)
   Zip and unzip files in Swift.
   pod 'Zip', '~> 0.4.3'
   - Homepage: https://github.com/marmelroy/Zip
   - Source:   https://github.com/marmelroy/Zip.git
   - Versions: 0.4.3, 0.4.1, 0.4.0, 0.3.4, 0.3.2, 0.3.1, 0.3.0, 0.2.0, 0.1.5,
   0.1.4, 0.1.3, 0.1.2 [master repo]

Swift3.0 errors when using `pod lib lint mylib.podspec` in our Pod

In our Pod iOSDFULibrary we have Zip as a dependency, currently using 0.6 with Swift3 support.

When I try to pod lib lint iOSDFULibrary.podspec while using Xcode 8 , I get those errors, which seem like Xcode is not using Swift3, I'm guessing ? I only have Xcode8 installed, any tips appreciated!

- ERROR | xcodebuild: Returned an unsuccessful exit code. You can use `--verbose` for more information.
    - WARN  | xcodebuild:  Zip/Zip/QuickZip.swift:24:38: warning: extraneous '_' in parameter: 'path' has no keyword argument name
    - ERROR | xcodebuild:  Zip/Zip/QuickZip.swift:40:63: error: expected type
    - ERROR | xcodebuild:  Zip/Zip/QuickZip.swift:40:63: error: expected ',' separator
    - WARN  | xcodebuild:  Zip/Zip/QuickZip.swift:40:38: warning: extraneous '_' in parameter: 'path' has no keyword argument name
    - ERROR | xcodebuild:  Zip/Zip/QuickZip.swift:41:39: error: expected member name following '.'
    - ERROR | xcodebuild:  Zip/Zip/QuickZip.swift:41:39: error: consecutive statements on a line must be separated by ';'
    - ERROR | xcodebuild:  Zip/Zip/QuickZip.swift:41:39: error: 'default' label can only appear inside a 'switch' statement
    - ERROR | xcodebuild:  Zip/Zip/QuickZip.swift:98:1: error: expected '}' at end of brace statement
    - NOTE  | xcodebuild:  Zip/Zip/QuickZip.swift:40:106: note: to match this opening '{'
    - ERROR | xcodebuild:  Zip/Zip/QuickZip.swift:98:1: error: expected declaration
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:85:119: error: expected type
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:85:119: error: expected ',' separator
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:88:39: error: expected member name following '.'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:88:39: error: consecutive statements on a line must be separated by ';'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:88:39: error: 'default' label can only appear inside a 'switch' statement
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:234:146: error: expected type
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:234:146: error: expected ',' separator
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:237:39: error: expected member name following '.'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:237:39: error: consecutive statements on a line must be separated by ';'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:237:39: error: 'default' label can only appear inside a 'switch' statement
    - ERROR | xcodebuild:  Zip/Zip/ZipUtilities.swift:14:35: error: expected member name following '.'
    - ERROR | xcodebuild:  Zip/Zip/ZipUtilities.swift:14:35: error: consecutive declarations on a line must be separated by ';'
    - ERROR | xcodebuild:  Zip/Zip/ZipUtilities.swift:14:35: error: expected declaration
    - ERROR | xcodebuild:  Zip/Zip/QuickZip.swift:24:61: error: use of undeclared type 'URL'
    - ERROR | xcodebuild:  Zip/Zip/QuickZip.swift:40:102: error: use of undeclared type 'URL'
    - WARN  | xcodebuild:  Zip/Zip/Zip.swift:85:33: warning: extraneous '_' in parameter: 'zipFilePath' has no keyword argument name
    - WARN  | xcodebuild:  Zip/Zip/Zip.swift:343:48: warning: extraneous '_' in parameter: 'fileExtension' has no keyword argument name
    - WARN  | xcodebuild:  Zip/Zip/Zip.swift:355:46: warning: extraneous '_' in parameter: 'fileExtension' has no keyword argument name
    - WARN  | xcodebuild:  Zip/Zip/Zip.swift:364:49: warning: extraneous '_' in parameter: 'fileExtension' has no keyword argument name
    - WARN  | xcodebuild:  Zip/Zip/Zip.swift:375:44: warning: extraneous '_' in parameter: 'fileExtension' has no keyword argument name
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:13:23: error: use of undeclared type 'Error'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:85:48: error: use of undeclared type 'URL'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:85:66: error: use of undeclared type 'URL'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:234:40: error: use of undeclared type 'URL'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:234:59: error: use of undeclared type 'URL'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:13:13: error: type 'ZipError' does not conform to protocol 'RawRepresentable'
    - NOTE  | xcodebuild:  Swift.RawRepresentable:9:20: note: protocol requires nested type 'RawValue'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:101:57: error: argument 'count' must precede argument 'repeating'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:106:71: error: use of unresolved identifier 'path'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:107:51: error: use of unresolved identifier 'FileAttributeKey'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:111:31: error: use of unresolved identifier 'Progress'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:114:32: error: use of unresolved identifier 'ProgressKind'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:117:29: error: use of unresolved identifier 'path'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:122:28: error: thrown expression type 'ZipError' does not conform to 'ErrorType'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:125:40: error: value of type 'String' has no member 'cString'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:126:17: error: use of unresolved identifier 'ret'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:129:17: error: use of unresolved identifier 'ret'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:131:16: error: use of unresolved identifier 'ret'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:132:32: error: thrown expression type 'ZipError' does not conform to 'ErrorType'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:135:34: error: use of unresolved identifier 'MemoryLayout'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:136:13: error: use of unresolved identifier 'ret'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:137:16: error: use of unresolved identifier 'ret'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:139:32: error: thrown expression type 'ZipError' does not conform to 'ErrorType'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:144:28: error: type 'UnsafeMutablePointer<CChar>' (aka 'UnsafeMutablePointer<Int8>') has no member 'allocate'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:151:32: error: thrown expression type 'ZipError' does not conform to 'ErrorType'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:160:50: error: use of unresolved identifier 'CharacterSet'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:166:32: error: use of unresolved identifier 'Date'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:167:40: error: use of unresolved identifier 'FileAttributeKey'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:168:40: error: use of unresolved identifier 'FileAttributeKey'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:180:17: error: use of unresolved identifier 'ret'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:193:20: error: value of optional type 'UnsafeMutablePointer<FILE>?' not unwrapped; did you mean to use '!' or '?'?
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:196:32: error: thrown expression type 'ZipError' does not conform to 'ErrorType'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:198:13: error: use of unresolved identifier 'ret'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:202:49: error: argument passed to call that takes no arguments
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:207:18: error: use of unresolved identifier 'ret'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:207:35: error: use of unresolved identifier 'ret'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:211:29: error: argument passed to call that takes no arguments
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:252:21: error: use of unresolved identifier 'processedPaths'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:264:31: error: use of unresolved identifier 'Progress'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:267:32: error: use of unresolved identifier 'ProgressKind'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:270:27: error: use of unresolved identifier 'destinationPath'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:271:21: error: use of unresolved identifier 'processedPaths'
    - ERROR | xcodebuild:  Zip/Zip/Zip.swift:330:29: error: argument passed to call that takes no arguments
    - WARN  | xcodebuild:  Zip/Zip/ZipUtilities.swift:37:35: warning: extraneous '_' in parameter: 'paths' has no keyword argument name
    - WARN  | xcodebuild:  Zip/Zip/ZipUtilities.swift:63:43: warning: extraneous '_' in parameter: 'directory' has no keyword argument name
    - ERROR | xcodebuild:  Zip/Zip/ZipUtilities.swift:20:26: error: use of undeclared type 'URL'
    - ERROR | xcodebuild:  Zip/Zip/ZipUtilities.swift:37:45: error: use of undeclared type 'URL'
    - ERROR | xcodebuild:  Zip/Zip/ZipUtilities.swift:63:56: error: use of undeclared type 'URL'

Remove Package.swift ?

I saw that there is a Package.swift file, however the library uses mixed languages (c, etc..) for Zip support, making it not available for SPM (yet), maybe it's better to remove that file to avoid developers assuming that it'll work ?

Need to add Zip manually

I have to add Zip manually and I don't know how.
I don't want to use Pod or Carthage. Is it possible?

Zipping a folder

I tested this this library with zipping a bunch of files inside a folder and it works great. However zipping that said folder itself results in a file of a format called CPGZ when it is unzipped.

screen shot 2016-01-21 at 9 06 42 am

Is zipping a folder not supported or am I doing something wrong? Here's the snippet of code.

do {
    let folderPath = NSBundle.mainBundle().bundleURL.URLByAppendingPathComponent("My Images")
    try Zip.zipFiles([folderPath], zipFilePath: zipPath, password: nil, progress: { progress in
        print(progress)
    })
} catch {
    print("Zipping failed :(")
}

I've uploaded a demo project to Dropbox here.

Zip file extension validation

Great zip library but the file extension validation is making it difficult to use for me. I download a file with NSURLSession and it doesn't have the .zip extension (but it is a zip file though). Now I have to explicitly rename the file to .zip to pass the extension validation.

Would you consider removing the validation? Or making it optional?

Missing required module "minizip"

I installed Zip using carthfile and when I try to build this framework I get information about missing module "minizip". What do I need to do, to use this framework?

This does not work with macOS app files

I have archived an app I made from XCode. I zip it with the standard macOS compress from the right click menu.

But Zip does not upzip it properly. When I try to double click the app file, it says the file is corrupted.

Subfolders are added twice

If a folder with subfolders is zipped, all subfolders are added twice.
However: empty folder are not added at all.

Redefinition of module 'minizip'

So this is a new interesting issue in a library that I'm trying to get fixed, It's a combination of the Zip framework and how Carthage works I'd say, but thought of seeing what's your opinion, here's how the issue reproduces:

  • Create a new libray project, let's call it acme/greatLib
  • Create a Cartfile with marmelroy/Zip as the dependency
  • run carthage update --platform iOS, things looks great and the library works as it should.
  • Create a new project that will use acme/greatLib, the contents of cartfile will be acme/greatLib
  • run carthage update --platform iOS on that new project
  • Carthage will checkout both dependencies in to greatLib and Zip inside Carthage/Checkouts
  • Carthage will then build Zip first from checkout dir
  • Carthage then proceeds to build greatLib from it's checkout dir
  • greatLib now has it's own Carthage/Checkout directory with Zip checked out in there again (this is how most libraries work with carthage, expected behaviour)
  • All preparations are now done, time to setup the project.

Copying Zip.framework and greatLib.framework into the new project works ok, but the project will fail due to 'minizip.modulemap' has been defined twice, one time in the Zip/ checkout, and another time in greatLib/Carthage/Checkouts/Zip/

I'm kind of baffled on how to fix this, do you have any ideas ?
If nothing is resolvable here I might post the question to Carthage's issues to see if there's any feedback

for reference, here is the actual error code:

/Users/acme/Projects/testProject/Carthage/Checkouts/Zip/Zip/minizip/module.modulemap:1:8: error: redefinition of module 'minizip'
module minizip [system][extern_c] {
       ^
/Users/acme/Projects/testProject/Carthage/Checkouts/greatLib/Carthage/Checkouts/Zip/Zip/minizip/module.modulemap:1:8: note: previously defined here
module minizip [system][extern_c] {

Any tips would be appreciated :)

Does not work for command line tool

I am getting following error, when using on a Command Line Tool project:

dyld: Library not loaded: @rpath/Zip.framework/Versions/A/Zip
Referenced from: /Users/macOS/Library/Developer/Xcode/DerivedData/Test_Zip-cjrtsqmggijipgaqvctjpbltwtxs/Build/Products/Debug/Test_Zip
Reason: image not found
(lldb)

In a Cocoa Application project it works.
PS: I used Cocoapods to create the workspace.

EDIT:
It seems, that generally this is not possible: all libraries I tried gave this error when using in a Command Line Tool project. Why is this?

Error while unzip .zip archive

Hi, i'm triyng to unzip a .zip archive.
I've installed Zip by cocoapods and used like this :

        do {
            try Zip.unzipFile(NSURL(fileURLWithPath: docPath), destination: NSURL(fileURLWithPath: unzipedDocPath), overwrite: true, password: nil, progress: { (progress) -> () in
                print(progress)
            }) // Unzip

        } catch let error as NSError {
            print("Error: \(error)")
        }

But I get this error ...
Thank by the advence

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.