This is a cleaned up and modernized fork of ZipArchive by Aish, a class to simplify compressing and decompressing ZIP files in Objective-C.
- Add the ZIPArchive folder to your project.
- In the Build Phases tab for your target, under the Link Binary With Libraries section, add
libz.dylib
to the list of frameworks. #import "ZIPArchive.h"
Objective-C:
// Create ZIP file.
ZipArchive *zipArchive = [[ZipArchive alloc] initWithFileURL:myZipFileURL];
[zipArchive addFileToArchive:someFileURL];
[zipArchive addFileToArchive:anotherFileURL directoryPath:@"Some Folder"];
[zipArchive addDirectoryToArchive:someFolderURL directoryPath:@"Some Folder"];
[zipArchive writeToFile];
// Extract contents of ZIP file.
[ZIPArchive extractArchiveAtURL:myZipFileURL toDestination:aFolderURL];
Swift:
// Create ZIP file.
var zipArchive = ZIPArchive(fileURL: myZipFileURL)
zipArchive.addFileToArchive(someFileURL)
zipArchive.addFileToArchive(anotherFileURL, directoryPath: "Some Folder")
zipArchive.addDirectoryToArchive(someFolderURL, directoryPath: "Some Folder")
zipArchive.writeToFile()
// Extract contents of ZIP file.
ZIPArchive.extractArchiveAtURL(myZipFileURL, toDestination: aFolderURL)
ZIPArchive is released under the MIT License.