Swift and SwiftUI tutorials for Swift Developers

What is @main attribute

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

Xcode 12 shipped with Swift 5.3 which introduced the @main attribute.The @main attribute means this structure contains the entry point for the app. The App protocol takes care of generating the static main function that actually runs. When the app start, it displays this instance of ContentView, which is defined in the ContentView file. It’s a struct that conforms to the View protocol.

Leave a Reply

Your email address will not be published. Required fields are marked *

Previous Article

What is SwiftUI?

Next Article

How to use Section, List, header and footer in SwiftUI

Related Posts