Swift UI Deep Dive - Part 1
SwiftUI a first look
Welcome to the Explore SwiftUI Series
Welcome to this series of articles about SwiftUI! In this series, we’ll delve into the internals of SwiftUI by exploring the framework from a project-based perspective. The idea is to start with the template generated by Xcode and explain specific concepts of Swift that are used within it. Once we’ve covered the concepts from the template, we’ll add a few features to the project to explore additional concepts in greater depth.
Prerequisites
This series assumes that readers have a basic understanding of the Swift programming language. Specifically, you should be familiar with:
- Variable declarations
- Optionals
- Classes, structs, and protocols
- Closures
Creating a New SwiftUI App in Xcode.
If you create a project using the iOS template and pick SwiftUI as the interface in Xcode should generate you a file structure similar to this one.

Understanding the App Entry Point.
We will focus on the ExploreSwiftUIApp and espcially on how does SwiftUI collaborate with plaform to find our app entry point.
import SwiftUI
@main
struct ExploreSwiftUIApp: App {
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
The first line, import SwiftUI, is straightforward. But the next interesting part is the @main attribute.
In traditional programming languages like C, C++, or even early Swift apps, programs start from a main() function. However, if you search for a main() function in a SwiftUI app, you won’t find one.
The @main attribute
The @main annotation defines the entry point of our program. If you refer to the Swift documentation it mentions “The type must provide a main type”
The examples following are defining a static func main() but if you check our app code we don’t see it explicitely.
In the case of a SwiftUI application, the main function is defined by having the ExploreSwiftUIApp conform to the App protocol.
The App protocol defines a default implementation for the main function in one of it’s extension. As Apple documentation mentioned *the default implementation of the method that manages the launch process in a platform-appropriate way.
In other words:
✅ @main tells Swift where the program starts.
✅ Conforming to App provides the logic needed to launch and display your first window. (IE defines a main() function for us)
What’s Next?
In the next article I will describe what are the Scene and WindowGroup.
Summary
By now, we know:
SwiftUI apps don’t require a manual main() function.
The @main attribute marks the app’s entry point.
Conforming to the App protocol provides a default main() implementation.
SwiftUI then launches the app and displays the first scene defined in the body.