WKWebView and the sandbox

(Swift, macOS, storyboard)


I just try to display a web site inside the app. But I see nothing. It fails silently


import Cocoa
import WebKit

class ViewController: NSViewController {

    @IBOutlet weak var webView: WKWebView!
   
    override func viewDidLoad() {
        super.viewDidLoad()
       
        let url = URL(string: "https://www.apple.com")
        let request = URLRequest(url:url!)
        webView.load(request)
       
    }

}


There is a similar question here:

https://forums.developer.apple.com/thread/92265


It talks about the sandbox but I do not understand what I have to do. What I have to select and why?


Thank you

Answered by Claude31 in 396386022

I checked again, on different machines, and it works with OSX 10.14.6.


So, may be a bug in 10.15. You should file a bug report.

Reported here as well:

https://forums.developer.apple.com/thread/120248

You need to enable outgoing connections.


In XCode, select the project (topmost left with blue icon)

Select Targets

Select Signing and Capabilities

Open App Sandbox section

check ON 'Outgoing Connections'


https://stackoverflow.com/questions/47375217/mac-osx-app-not-loading-url-in-webkit-view

This is what I tried before asking. I tried again and it gives me that error. It is the same line repeated multiple times with different numbers. (1-macOS is the name of the project)

2019-11-28 10:17:59.427279+0100 1-macOS[1082:32145] [Process] kill() returned unexpected error 1


I tested on OSX 10.14.6, XCode 11.3 beta, and it works pretty well.


What is your configuration ?


If you want to send an email, we can exchange both projects.

Accepted Answer

I checked again, on different machines, and it works with OSX 10.14.6.


So, may be a bug in 10.15. You should file a bug report.

Reported here as well:

https://forums.developer.apple.com/thread/120248

WKWebView and the sandbox
 
 
Q