swift - 使用 SwiftUI、XCode 12 和 Catalina 的新项目失败
问题描述
我正在尝试创建一个新的 XCode 项目,全新的,我可以在模拟器上运行它,但在画布上它说:Cannot preview in this file - active scheme does not build this file
如果最重要的是我开始添加 macOS 支持,它说:
'appName' is annotated with @main and must provide a main static function of type () -> Void or () throws -> Void.
它还说:
Cannot find type 'App' in scope
Cannot find type 'Scene' in scope
关于我正在阅读的 mac 支持,有一个解决方法,即使我尝试过并且错误仍然存在。
至于活动方案,我读过这个,但没有帮助。我的意思是......一个新项目中只有一个方案,它是自动选择的
我会假设一个简单的 hello world 项目会起作用,这是怎么回事?
解决方案
macOS 上的 SwiftUI 2.0仅从Big-Sur macOS 11.0开始可用
@available(iOS 14.0, macOS 11.0, tvOS 14.0, watchOS 7.0, *)
public protocol App {
^^^^^^^^^^^^
推荐阅读
- git - 用空的 git commit 触发 CI/CD 有什么意义?
- c# - 需要在 C# 中调整高分辨率图像(300 dpi)的大小
- javascript - 导入本地下载的 pdfjs 库
- firebase - 如何通过 API 将授权域添加到 Firebase 身份验证?
- scala - 在 Spark (Scala) 中将时间戳转换为字符串而不会丢失毫秒
- ansible - 将ssl证书从服务器复制到ansible中的主机
- node.js - 将新字段添加到strapi后端的上下文变量以进行用户管理
- react-native - 识别从 WP REST API 检索数据的反应原生应用程序
- python - 在Python中的字符串列表中提取特定字符串
- linechart - 提高 CAShapeLayer 绘制的折线图的性能