[swift4] How to install SSZipArchive for un-zip file downloaded
How to install SSZipArchive for un-zip file downloaded, is below
SSZipArchive is a library for zip/un-zip files
https://github.com/ZipArchive/ZipArchive
目次
Create pod file
after prepare to use pod, move the folder where project located at console
pod init
Run above command
Add below red code on Pod file created newly
# Uncomment the next line to define a global platform for your project
# platform :ios, '9.0'
target 'Your Project Name' do
# Comment the next line if you're not using Swift and don't want to use dynamic frameworks
use_frameworks!
# Pods for textCollection
pod 'SSZipArchive'
target 'textCollectionTests' do
inherit! :search_paths
# Pods for testing
end
target 'textCollectionUITests' do
inherit! :search_paths
# Pods for testing
end
end
pod Install
Move the folder where pod file located at console
pod install
Run above command
Install/Use SSZipArchive
After pod install, workspace file created automatically, open this file on xcode
You can zip/un-zip below code
import SSZipArchive // Create SSZipArchive.createZipFile(atPath: <#T##String#>, withContentsOfDirectory: <#T##String#>) // Create with password SSZipArchive.createZipFile(atPath: <#T##String#>, withContentsOfDirectory: <#T##String#>, withPassword: <#T##String?#>) // Unzip SSZipArchive.unzipFile(atPath: <#T##String#>, toDestination: <#T##String#>) // Unzip with Password do { try SSZipArchive.unzipFile(atPath: <#T##String#>, toDestination: <#T##String#>, overwrite: <#T##Bool#>, password: <#T##String?#>) }catch (let error) { print(error) } // Unzip and Delete zip file SSZipArchive.unzipFile(atPath: <#T##String#>, toDestination: <#T##String#>, progressHandler: { _,_,_,_ in }, completionHandler: { _,_,_ in try! FileManager.default.removeItem(atPath: <#T##String#>) })
Value is String