新项目使用 SwiftUI、XCode 12 和 Catalina 失败
New project fails using SwiftUI, XCode 12 and Catalina
我正在尝试创建一个新的 XCode 项目,全新的,我可以在模拟器上 运行 它,但在 canvas 上它说: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 支持,我正在阅读有一个 ,即使我尝试了,错误仍然存在。
关于主动方案,我看了,但没有帮助。我的意思是...新项目中只有1个方案,并且自动选择了它
我假设一个简单的 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 {
^^^^^^^^^^^^
关于 macOS 支持是 Asperi 提到的,在 Catalina 上支持 mac 在 XCode 12.
上有问题
至于新建项目失败,我发现如果我按Cmd + Opt + P
,它会在Canvas上建立它。我曾尝试在 canvas 上单击“再试一次”,我认为它是相同的但没有用。您不需要删除文件并创建一个新文件,也不需要 select 任何目标,因为它是一个新项目并且目标是自动 selected 的。
此外 @Main
不必在 iOS 和 iPad 上更改为 运行,因为 macOS 支持只需等到 Big Sur发布。
我正在尝试创建一个新的 XCode 项目,全新的,我可以在模拟器上 运行 它,但在 canvas 上它说: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 {
^^^^^^^^^^^^
关于 macOS 支持是 Asperi 提到的,在 Catalina 上支持 mac 在 XCode 12.
上有问题至于新建项目失败,我发现如果我按Cmd + Opt + P
,它会在Canvas上建立它。我曾尝试在 canvas 上单击“再试一次”,我认为它是相同的但没有用。您不需要删除文件并创建一个新文件,也不需要 select 任何目标,因为它是一个新项目并且目标是自动 selected 的。
此外 @Main
不必在 iOS 和 iPad 上更改为 运行,因为 macOS 支持只需等到 Big Sur发布。