And how can I fix this problem?
It means you did not include import WebKit
in whatever file you tried to create a WKWebView
.
The class WKWebView
belongs to the WebKit
framework, so you have to import that framework whenever you want to use it, just like you have to import UIKit
, SwiftUI
, Combine
, MapKit
, CoreData
or AVKit
(among others) if you want to use them.
That’s a different error. Do you have a WKWebView
in your storyboard that is hooked up to the webView
outlet?
One thing you need to do in order to get WebKit to work these days is to add the WebKit framework to the App.
You do that by selecting the upper level Folder in the Project Navigator window and then select ‘Targets’ then the ‘General’ tab, then scroll down the page to bring “Frameworks, Libraries and Embedded Content” into view, tap on the + button and in the search bar of the window presented type WebKit and then select WebKit.framework from the list and click on Add.