Side-Note
The Development section is for discussing the compiler itself. Questions relating using the language need to go in the Using Swift section.
Answer
_main
is the entry point of the process. Without it, the OS doesn't know where to begin executing the binary.
In Swift, you have two ways of providing that entry point:
- A
main.swift
file which contains script-like top-level code that will be executed on processes launch. - The
@main
attribute that can be attached on a type, in which case the program begins by executing astatic func main()
(may bestatic
orclass
, may also beasync
and/orthrows
).
In your case, since you're using SwiftUI, the type that provides such a main
static method is App
.
You are either missing an implementation of the App
protocol entirely, or your implementation is missing the @main
attribute.
If you create a new SwiftUI app from a template in Xcode, it will generate all the code you need for the implementation of the App
protocol.