I’ve used ZIPFoundation

let archive = Archive(accessMode: .create) // Create it in memory

// Add a file
try archive?.addEntry(with: "export/photos/\(photo_id)", fileURL: filename)


// Add string as a file
try archive?.addEntry(with: "export/data.csv", type: .file, uncompressedSize: UInt32(output.count)) { position, size in
                return output.data(using: .utf8)!
            }

// Write ZIP as a file
if let data = archive?.data {
    let exportFile = FileManager.default.temporaryDirectory.appendingPathComponent("export.zip")
    print("Path: \(exportFile.path)")
    try data.write(to: exportFile)
}