Вы можете использовать собственный фреймворк Swift, который позволяет создавать, читать и обновлять файлы ZIP-архивов: ZIP Foundation.
Распаковка файла - это всего одна строка:
try fileManager.unzipItem(at: sourceURL, to: destinationURL)
Полный пример с некоторым контекстом будет выглядеть так:
let fileManager = FileManager()
let currentWorkingPath = fileManager.currentDirectoryPath
var sourceURL = URL(fileURLWithPath: currentWorkingPath)
sourceURL.appendPathComponent("archive.zip")
var destinationURL = URL(fileURLWithPath: currentWorkingPath)
destinationURL.appendPathComponent("directory")
do {
try fileManager.createDirectory(at: destinationURL, withIntermediateDirectories: true, attributes: nil)
try fileManager.unzipItem(at: sourceURL, to: destinationURL)
} catch {
print("Extraction of ZIP archive failed with error:\(error)")
}
Вы можете проверить GitHub репозиторий: ZIPFoundation
Блог для ZIPFoundation: ZIPFoundation