2

I'm using macOS Veneer and Xcode 14 to develop a macOS application with a target development set to macOS 10.15. As I'm new to coding with SwiftUI, I encountered a few errors when I changed the target to macOS 10.15:

  1. "'main()' is only available in macOS 11.0 or newer"
  2. "'Scene' is only available in macOS 11.0 or newer"
  3. "'WindowGroup' is only available in macOS 11.0 or newer" I'm seeking guidance on how to set up the project to enable SwiftUI coding while targeting macOS 10.15. I've noticed that there is no AppDelegate.swift file in the default project template.

I'm aware that starting from Xcode 12, SwiftUI became available. Are there any resources or links where I can download default project templates for older Xcode versions? My computer will now allow me to open older Xcode versions.

1 Answer 1

2

SwiftUI first shipped with Xcode 11 in 2019 and supported macOS 10.15 (Catalina). But the SwiftUI app lifecycle, which includes the App and Scene protocols, the WindowGroup type, and the @main annotation, first appeared in Xcode 12 in 2020 and required macOS 11 (Big Sur).

If you want to support macOS 10.15, you cannot use the SwiftUI app lifecycle. You need to use the AppKit lifecycle. To do that, when creating your project, choose the macOS App project template. Then, for the Interface option, choose either Storyboard or XIB. These options are still available as of Xcode 15.0 beta 1, so you should not need to download any other resources.

Please be aware that SwiftUI has improved a lot since macOS 10.15. You may find that developing an app that uses SwiftUI and supports macOS 10.15 is simply more trouble than it’s worth. At a minimum you’ll need to test your user interface thoroughly on macOS 10.15 and not just on later versions, because there have been a lot of bug fixes and subtle behavioral changes in later releases. My day job involves maintaining an in-house Mac app, and I didn’t find it worthwhile to start using SwiftUI until all my users were on at least macOS 12.

You can run macOS 10.15 in a virtual machine for testing, but (I think) only if you have an Intel Mac. I do not think Apple Silicon Macs can run an Intel VM, and macOS 10.15 didn’t support Apple Silicon.

Sign up to request clarification or add additional context in comments.

2 Comments

Are you saying that we basically create a Storyboard Project or XIB project and if we want to use SwiftUI we just embed it as a view?
Yes. That was the only way to use SwiftUI in macOS 10.15 (and iOS 13).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.