WKWebView in Popover does not load any content

Hey guys,


I'm trying to add a WebView to show a web content in the popover. Here's what I have:



class SafariExtensionViewController: SFSafariExtensionViewController, WKNavigationDelegate {


static let shared = SafariExtensionViewController()


var webView : WKWebView!


override func viewDidLoad() {

super.viewDidLoad()

self.preferredContentSize = NSMakeSize(550, 450)

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


self.webView.translatesAutoresizingMaskIntoConstraints = false


self.webView.navigationDelegate = self

let myURL = URL(string:"https://www.apple.com")

let myRequest = URLRequest(url: myURL!)

webView.load(myRequest)

self.view.addSubview(self.webView)

}

}


For some reasons the webview shows up as blank, and does not appear to load any content at all. I've tried HTTPS and HTTP sources, all ended the same. I also added the App Transport Security properties in the Info.plist and allowed both Arbitrary Loads and Arbitrary Loads in Web Content.


In addition, all the WKNavigationDelegate functions are not called either.


Any insight would be greatly appreciated!

CM

Accepted Reply

Found a solution! It turns out that the App Sandboxing in the Capabilities section needs to be turned on, and enable Outgoing network requests (as client).

Replies

Found a solution! It turns out that the App Sandboxing in the Capabilities section needs to be turned on, and enable Outgoing network requests (as client).