xcode 没有这样的模块“UIKit”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/46901881/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 10:23:01  来源:igfitidea点击:

No such module 'UIKit'

xcodemacoswkwebview

提问by Taylor A. Leach

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

我想要做的就是制作最基础的 mac OS X 应用程序,它只显示一个 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

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

回答by cbiggin

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

UIKit 适用于移动应用程序,而不是 MacOS 应用程序。你想要 AppKit。

回答by Orhan ?zker?in

  • Open utilities from the top right corner
  • Change the platform to IOS
  • 从右上角打开实用程序
  • 换平台为IOS

Then it should be okay to use UIKit

那么使用UIKit应该就可以了

回答by Gsuit

Check the 'show utilities' window. If the platform is set to MacOS, you'll get this error if you're calling UIKit. Same thing goes if your wanting IoS and your calling AppKit.

检查“显示实用程序”窗口。如果平台设置为 MacOS,则在调用 UIKit 时会出现此错误。如果您想要 IoS 和您调用 AppKit,同样的事情也会发生。

http://iosbrain.com/blog/2018/08/16/xcode-9-playground-error-no-such-module-uikit-or-appkit/