WKDownloadManager is used to manage downloads from WKWebView and is a lightweight and easy to use package.
iOS 14.5 or later
Package Manager support from Xcode 11+ :
- Select File -> Swift Packages -> Add Package Dependency. Enter
https://github.com/kuttz/WKDownloadManager
in the "Choose Package Repository" dialog. - In the next page, specify the version resolving rule.
- After Xcode checked out the source and resolving the version, you can choose the "WKDownloadManager" library and add it to your app target.
-OR-
Alternatively, you can also add CountryDialCode to your Package.swift
file:
dependencies: [
.package(url: "https://github.com/kuttz/WKDownloadManager", branch: "main")
]
For more info, read Adding Package Dependencies to Your App from Apple.
fileprivate var downloadManager: WKDownloadManager!
let mimeTypes = ["image/svg+xml",
"image/png",
"image/jpeg",
"application/pdf"]
downloadManager = WKDownloadManager(delegate: self,
supportedMimeTypes: mimeTypes)
webView.navigationDelegate = downloadManager