Maxwell Patrick
Maxwell Patrick

Reputation: 23

Xcode Cannot find type 'WKWebView' in scope error on Xcode 12.5.1

I am creating an app that uses WKWebView to display a website. However, when I run this (in ViewController.swift):

import UIKit

class ViewController: UIViewController {
    @IBOutlet var WebsiteView: WKWebView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
        WebsiteView.loadHTMLString("<iframe width=\"\(WebsiteView.frame.width)\" height=\"\(WebsiteView.frame.height)\" src=\"http://example.com\"></iframe>", baseURL: nil)
    }
}

it throws 2 errors. The main one is this: Cannot find type 'WKWebView' in scope The other one is this: 'nil' requires a contextual type. Any help would be appreciated!

Upvotes: 0

Views: 1907

Answers (1)

Abdul Waheed
Abdul Waheed

Reputation: 894

You need to import a Framework. Under import UIKit add

import WebKit

Upvotes: 1

Related Questions