The Archive Framework implements compression algorithms and supports for example the LZMA compression format. Unfortunately I was not able to find a way to generate a ZIP-kompatible archive using the Archive Framework though iOS / iPadOS seems to be able to do that, because the Files app and the Shortcuts app support this kind of compression.
Is there a way on iOS/iPadOS to generate an LZMA compressed archive with ZIP container using only apple provided APIs or other system services?
PS: I don't need full support for all possible ZIP features. I only need to create a simple archive containing some files which can be opened using any zip decompression program.
https://developer.apple.com/documentation/accelerate/compressing_file_system_directories
I only need to create a simple archive containing some files which can be opened using any zip decompression program.
While ebainville is correct that you can’t create zip archives using Apple Archive, it is possible to create a basic one using NSFileCoordinator
. Here’s a quick example:
let originalURL: URL = … your input directory …
let coordinator = NSFileCoordinator()
let zipIntent = NSFileAccessIntent.readingIntent(with: originalURL, options: [.forUploading])
coordinator.coordinate(with: [zipIntent], queue: .main) { errorQ in
if let error = errorQ {
… handle the error …
return
}
let zipURL = zipIntent.url
… work with the URL before returning …
… if necessary, copying it elsewhere …
}
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"