Extend WKWebView and iOS 7

import UIKit
import WebKit

protocol VCWebViewProvider: class {
}

class testclass {
    static var values : Dictionary<String, AnyObject> = ["one": true, "two": "two"]
}

@available(iOS 8.0, *)
extension WKWebView: VCWebViewProvider {
}

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()
   
        if #available(iOS 8.0, *) {
            let w = WKWebView()
            w.frame = self.view.frame
            w.autoresizingMask = [UIViewAutoresizing.FlexibleWidth, UIViewAutoresizing.FlexibleHeight]
            self.view.addSubview(w)
        } else {
            let w = UIWebView()
            w.frame = self.view.frame
            w.autoresizingMask = [UIViewAutoresizing.FlexibleWidth, UIViewAutoresizing.FlexibleHeight]
            self.view.addSubview(w)
        }
   
        if let test = testclass.values["one"] {
            // Crash happens here and only on an iOS 7.1 device (not simulator)
            print(test)
        }
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
}


When running on iOS 7.1.1 I get a crash in my sample program when I access a static variable. Debugging revealed that this crash only happens when I write an extension for the WKWebView. It does not change a thing if there are methods in this extension or not. The declaration itself is enough. As soon as I remove the protocol VCWebViewProvider from my WKWebView extension the program runs fine. I guess there is a problem because I add an extension with a protocol to a class which is not available in iOS 7. I marked the extension as available in iOS 8 but this is not changing the behavior. Additionally I get a crash in the AppDelegate when I want to run the app on iOS 9. The error does not happen when I change the deployment target to iOS 8 and does not produce a crash when I run the app without attaching the debugger but run the app directly from the springboard.


Does anyone know if I am doing anything wrong? I have also opened a ticket in the bug reporter: rdar://21541766

Extend WKWebView and iOS 7
 
 
Q