how do I get WKWebView to work in swift and for an macOS App

Solutions Collect From Internet About “how do I get WKWebView to work in swift and for an macOS App”

I recommend you to start from the scratch:

Set Your URL to be loaded:

let myURLString = "https:yourWebLink"
let url = NSURL(string: myURLString)
let request = NSURLRequest(URL: url!)  

Init and load request in webview:

    webView = WKWebView(frame: self.view.frame)
    webView.navigationDelegate = self

Implement WKNavigationDelegate to trace your page Load/Error:

func webView(webView: WKWebView, didFailProvisionalNavigation navigation: WKNavigation!, withError error: NSError) {
func webView(webView: WKWebView, didStartProvisionalNavigation navigation: WKNavigation!) {
    print("Strat to load")
func webView(webView: WKWebView, didFinishNavigation navigation: WKNavigation!) {
    print("finish to load")

Dont forget to add delegate WKNavigationDelegate in ViewController.swift file.

class ViewController: UIViewController , WKNavigationDelegate{

For further reference check: