针对目标 macOS 10.15 使用 Xcode 12 构建错误

Dis*_*sco 4 macos xcode swiftui

从 Xcode 12.3 开始,当您使用 macOS 目标创建新的 SwiftUI 项目时,Xcode 默认目标为 11.0 (Big Sur)。不更改默认创建的默认“hello world”应用程序中的一行代码,然后我将目标更改为 macOS 10.15(这是我仍在使用的)默认项目 swift 文件将不再构建。:-


@main
struct catalinaApp: App {
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}```

3 Errors: @main, 'Scene' and WindowGroup is only available in macOS 11.0 or newer

How can I alter the project/above file to correctly build the default app on Catalina? (10.15) ?

thanks in advance!
Run Code Online (Sandbox Code Playgroud)

Dis*_*sco 9

感谢@Raja Kishan,答案很简单,在创建新项目时,在 Lifecycle 的选项中选择 App Delegate 选项。

  • 哇 - 两天搜索互联网并完全重新安装,这就是我所需要的 - 谢谢......!希望我能给这个+10。 (2认同)