A Swift package that compresses full web pages into single archive files that can later be loaded into a
WKWebView. It may be used to implement offline reading features.
The main method
.webarchive file. The archiver parallelizes HTTP requests, but works on a single serial queue to process the responses.
A sample project that demostrates how to combine the WebArchiver with
WKWebView can be found here: OfflineWebView
This repository is a Swift Package Manager package. Use Xcode to add it as a dependency. Or simply copy and paste the 3 source files into your project and add Fuzi as a dependency via your package manager of choice.
This package was created because
WKWebView (in contrast to the deprecated
UIWebView) does not offer a universal way to make arbritary web content available offline. WebKit's own HTTP caching unfortunately does provide enough control for most use cases, and a lot of stuff happens "out-of-process" (see here or here).
WKWebView can import
.webarchive files, which are binary PLIST files following a defined (undocumented) format. Being able to create
.webarchive therefore allows apps to save online content to offline reading. Such files can be loaded into the
loadFileURL(URL:allowingReadAccessTo:) where URL is a
The package uses Fuzi as HTML parser.