Xcode-9-beta1 (9M136h): Runtime error on registering a custom https handler

Originator:andrew
Number:rdar://32670611 Date Originated:9/6/2017
Status:Open Resolved:
Product:iOS SDK Product Version:iOS 11 Xcode-9-beta1 (9M136h)
Classification:Serious Bug Reproducible:Always
 
32670611

Xcode-9-beta1 (9M136h): Runtime error on registering a custom https handler

Summary:

Attempting to intercept https requests via WKWebViewConfiguration and WKURLSchemeHandler results in a runtime error, which dramatically reduces the usefulness of this new API.

Steps to Reproduce:

Compile and run this code:

            let conf = WKWebViewConfiguration()
            conf.setURLSchemeHandler(UnilyURLSchemeHandler(), forURLScheme: "https")
            let webView = WKWebView(frame: self.view.bounds, configuration: conf)

Expected Results:

The ability to inspect and override all http and https requests (for example to allow custom offline caching).

Actual Results:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: ''https' is a URL scheme that WKWebView handles natively'

Regression:

N/A

Notes:

I will attempt to work around this using find-and-replace on https:// in all source data. But that's really ugly. The API should not be so restrictive and force nasty hacks like this.


iOS Version/Build
iOS 11 Xcode-9-beta1 (9M136h)

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!