Xcode preview docx file with WKWebview

Running on macOS Big Sur (11.0.1), the code below perfectly loads and displays images, pdfs, html in a WKWebview but not docx or other files. I would like to preview files selected in my Mac app.

I get this error:
WebPageProxy::didFailProvisionalLoadForFrame: frameID = 3, domain = WebKitErrorDomain, code = 102


Please can someone help? Thank you.


import Cocoa

import WebKit

class ViewController: NSViewController {
Code Block
@IBOutlet weak var webView: WKWebView!
let url = "https://filesamples.com/samples/document/docx/sample3.docx"

override func viewDidLoad() {
super.viewDidLoad()
Code Block
// Do any additional setup after loading the view.
let request = URLRequest(url: URL(string: url)!)
webView.load(request)
}
}
Hi saeidg.

I have the exact same problem, but only on macOS apps. On iOS, the .docx, .doc and other formats load just fine. On macOS I get the same error as you have mentioned "WebPageProxy::didFailProvisionalLoadForFrame: frameID = 3, domain = WebKitErrorDomain, code = 102"

My XCode Version is 12.3 (12C33) - the latest available as of now. I got rid of the App sandbox, but that didn't help.

Thanks!
Xcode preview docx file with WKWebview
 
 
Q