Unzipping downloaded files in iOS

Using ASIHTTPRequest, I downloaded a zip file containing a folder with several audio files. I tried to unzip the file with SSZipArchive and ZipArchive, which are both based on minizip.

When I compile the code, I get this error: Undefined symbols for architecture i386: "_OBJC_CLASS_$_ZipArchive", referenced from: objc-class-ref in AppDelegate.o.

How do I unzip this file in iOS?


I've used ZipArchive with success in the past. It's pretty ligthweight and simple to use, supports password protection, multiple files inside a ZIP, as well as compress & decompress.

The basic usage is:

NSString *filepath = [[NSBundle mainBundle] pathForResource:@"ZipFileName" ofType:@"zip"];
ZipArchive *zipArchive = [[ZipArchive alloc] init];
[zipArchive UnzipOpenFile:filepath Password:@"xxxxxx"];
[zipArchive UnzipFileTo:{pathToDirectory} overWrite:YES];
[zipArchive UnzipCloseFile];
[zipArchive release];

more examples about this package here

I have also tried SSZipArchive in some projects. Below line would unzip your zip file.

[SSZipArchive unzipFileAtPath:path toDestination:destination];

To start, in iOS 7, Apple introduced the ability to natively zip / unzip files. You also have the option so send the zip files through Mail, Messages, Airdrop and "Open in". The key is: The zip file has to be supported by iOS Some are, and some are not. The first step: Find out if your file is supported. Do this by a simple check of your newly saved file. Try to open it. If it is stuck of "Waiting..." it is probably not supported. Try a different library or use a workaround if this is the case.

Now, doing this programmatically Currently requires the use of a third party library to save zip files and extract them. This is not ideal, since a lot of people / companies avoid using them. That being said, the answer marked correct, ZipArchive is a great third party tool, especially since it now supports Swift. I would recommend using it until Apple introduces a native library.