Need help with WKWebKit browser loading website (macOS)

I can't seem to get a website to load on my macOS web browser app. This is the code am using:

        @IBOutlet weak var web: WKWebView! 

        let purl = URL(string: "https://www.google.com")!

        web.load(URLRequest(url: purl))

        web.allowsBackForwardNavigationGestures = true

A common cause for your issue is the App Sandbox is turned on with network connections turned off. When the network connections are turned off, you won't be able to show anything in a web view.

Select the project from the left side of the project window to open the project editor. Select your app target from the left side of the project editor. Click the Signing and Capabilities button at the top of the project editor.

Is there an App Sandbox section? If so, make sure the checkboxes in the Network section are selected.

Is the code you showed the whole code you're using for the web view? The code you showed needs to be part of a view controller class with the outlet as a property in the class and the other three lines inside the viewDidLoad function.

class ViewController: NSViewController {

    @IBOutlet weak var web: WKWebView!

    override func viewDidLoad() {
        super.viewDidLoad()
        let purl = URL(string: "https://www.google.com")!
        web.load(URLRequest(url: purl))
        web.allowsBackForwardNavigationGestures = true
    }
}
Need help with WKWebKit browser loading website (macOS)
 
 
Q