Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No such module 'UIKit'

All I want to do is make the most BASIC mac OS X app that just shows a WKWebView...

import UIKit
import WebKit
class ViewController: UIViewController, WKUIDelegate {

var webView: WKWebView!

override func loadView() {
    let webConfiguration = WKWebViewConfiguration()
    webView = WKWebView(frame: .zero, configuration: webConfiguration)
    webView.uiDelegate = self
    view = webView
}
override func viewDidLoad() {
    super.viewDidLoad()

    let myURL = URL(string: "https://www.apple.com")
    let myRequest = URLRequest(url: myURL!)
    webView.load(myRequest)
}}

https://developer.apple.com/documentation/webkit/wkwebview

like image 335
Taylor A. Leach Avatar asked Oct 24 '17 03:10

Taylor A. Leach


People also ask

How do I import UIKit?

To import the UIKit: Navigate to Site Studio > Sync packages > Import packages.

Is UIKit available for macOS?

Mac Catalyst, also refereed to as "UIKit for Mac", allows you to build [iOS and iPadOD](iOS projects to run natively on the Mac, while still being utilizing the UIKit and other iOS specific APIs and design paradigms. Applications build for this mode can also mix in AppKit and other macOS-specific frameworks.

What is AppKit Apple?

AppKit contains all the objects you need to implement the user interface for a macOS app—windows, panels, buttons, menus, scrollers, and text fields—and it handles all the details for you as it efficiently draws on the screen, communicates with hardware devices and screen buffers, clears areas of the screen before ...


2 Answers

if you already selected iOS while creating Playground file but still getting error No such module 'UIKit', then follow following steps. Xcode 13 enter image description here

enter image description here

enter image description here

Step By Step Action

like image 173
gsk_fs Avatar answered Oct 27 '22 08:10

gsk_fs


UIKit is for mobile apps, not MacOS apps. You want AppKit.

like image 33
cbiggin Avatar answered Oct 27 '22 08:10

cbiggin