ΩlostA
ΩlostA

Reputation: 2601

iOS/Swift: How to unzip files by importing Github (or else) files manually? Error Domain=SSZipArchiveErrorDomainUserInfo failed to open zip file

I tried to use the ZipArchive framework for unzipping a zip file, but I don't understand the problem. It doesn't tell me some error, but I could not find my unzipped files/folders.

// Unzip
let sourceURL = localUrl.stringByAppendingPathComponent(path: "TEMP.zip")
let destinationURL = localUrl.stringByAppendingPathComponent(path: "TEST")
SSZipArchive.unzipFile(atPath: sourceURL, toDestination: destinationURL)

EDIT: With the answer above, here is the error message:
Error Message: Error Domain=SSZipArchiveErrorDomain Code=-1 "failed to open zip file" UserInfo={NSLocalizedDescription=failed to open zip file}

EDIT2: I checked with the function fileExists, and file is available

let str = sourceURL

let url = URL(string: str)
print(url!.path,"\n")

if FileManager.default.fileExists(atPath: url!.path) {
    print("FILE IS AVAILABLE")
} else {
    print("FILE NOT AVAILABLE")
}

Thanks in advance

Upvotes: 0

Views: 556

Answers (0)

Related Questions