Posts

Post marked as solved
14 Replies
8.6k Views
I've been attempting to make a simple, test macOS app using WKWebView. I've seen lots of samples and basic tutorials, and this rudimentary sample code works when tested directly in the XCode environment:import Cocoa import WebKit class ViewController: NSViewController { @IBOutlet weak var webView: WKWebView! override func viewDidLoad() { super.viewDidLoad() var myURL: URL! myURL = URL(string: "https://developer.apple.com/") let myRequest = URLRequest(url: myURL!) webView.load(myRequest) } }When it runs, I see an app window with an embedded WKWebView frame, and the specified URL loads within that frame as expected.However, when I attempt to run the built app file directly on my iMac, all I get is an empty window. I don't even see the frame for the WKWebView object.The WKWebView was placed in the main.storyboard and the outlet was linked through the standard ctrl-drag operation. The entitlements for App Sandboxing and Network Outgoing Connections are set (otherwise, the URL won't load in Xcode, either).So, my question is -- should this work? I've seen comments around the web that one cannot implement WKWebView via Interface Builder in older versions of Xcode/macOS, but my tests show it currently works within Xcode 10.2 on macOS 10.14.4. Why would it work in Xcode but not in the built app itself? Am I missing something?
Posted
by ethur.
Last updated
.