NSURLSessionConfiguration has a direct interface (connectionProxyDictionary) for this, so it can be easily executed
But WkWebView does not have such a direct interface as it does, it requests, displays content outside the process and therefore you can imagine how the WkWebview instance is isolated from the rest of your application.
WkWeView even ignores cookies (NSHTTPCookieStorage), caches (NSURLCache) and credentials (NSCredentialStorage) NSURLSession and NSURLConnection, and these network classes cannot access cookies, caches, and credentials of a WkWebView instance.
UIWebView does not do this outside the process, so you can use NSURLProtocol, as shown in the CustomHTTPProtocol sample for the proxy server.
As with iOS 10, WkWebView does not support NSURLProtocol, so you cannot proxy using WkWebView.
If your proxy server supports tunneling (VPN), you can use NetworkExtension.framework and its classes (NEVPNManager, NEVPNProtocol, NEVPNConnection, etc.) to direct all the network traffic of your application through your proxy server.
Here is a tutorial on how to do this
source share