Apple's framework for displaying web content in your app. WebKit provides WKWebView for rendering HTML, CSS, and JavaScript with the same engine used by Safari.
of iOS users worldwide can use WebKit (iOS 8+ required)
| iOS Version | Market Share | Status |
|---|---|---|
| iOS 18.7 | 30.3% | Supported |
| iOS 18.6 | 29.8% | Supported |
| iOS 26.1 | 10.7% | Supported |
| iOS 18.5 | 6.0% | Supported |
| iOS 16.7 | 2.3% | Supported |
| iOS 26.2 | 2.0% | Supported |
| iOS 18.3 | 1.8% | Supported |
| iOS 15.8 | 1.8% | Supported |
| iOS 11.0 | 1.7% | Supported |
| iOS 17.6 | 1.7% | Supported |
Modern web content rendering
JavaScript execution
CSS and HTML5 support
Two-way communication with JavaScript
Content blocking and filtering
Custom URL scheme handling
Create a web view and load a URL
import WebKit
import UIKit
class WebViewController: UIViewController {
var webView: WKWebView!
override func loadView() {
let configuration = WKWebViewConfiguration()
webView = WKWebView(frame: .zero, configuration: configuration)
webView.navigationDelegate = self
view = webView
}
override func viewDidLoad() {
super.viewDidLoad()
if let url = URL(string: "https://www.apple.com") {
webView.load(URLRequest(url: url))
}
}
}
extension WebViewController: WKNavigationDelegate {
func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!) {
print("Finished loading")
}
}Run JavaScript code in the web view
import WebKit
func executeJavaScript(in webView: WKWebView) {
let script = "document.body.style.backgroundColor = 'lightblue';"
webView.evaluateJavaScript(script) { result, error in
if let error = error {
print("Error: \(error)")
} else {
print("Script executed")
}
}
}Apple's framework for displaying web content in your app. WebKit provides WKWebView for rendering HTML, CSS, and JavaScript with the same engine used by Safari.
WebKit is available on iOS 8 and later. Currently, 99.7% of iOS users worldwide can use this framework.
Related frameworks include Safariservices. Each has different capabilities and iOS version requirements.