0Pricing
SwiftUI Academy · レッスン

SwiftUI アプリ ファイルの構成

@main、App、WindowGroup、ContentView について理解します。

「SwiftUI アプリ ファイルの構成」はCoddyKit上の無料SwiftUI Academyレッスンです。 これはレッスン2/4です。 下記で完全なレッスンを無料で読むことができます。その後、ブラウザ内の組み込みコードエディタと24時間対応のAIチューターでハンズオン演習できます。 これはSwiftUI Academy学習パスの一部であり、ウェブとCoddyKitアプリ全体で進捗が同期されます。 SwiftUI Academyコースには全4レッスンが含まれています。

このレッスンの一部はまだ翻訳されておらず、英語で表示されています。

The App File

Every SwiftUI project has a file named after your app, like MyFirstApp.swift. This app file is the true entry point where your whole app begins. 📱

The @main Marker

The @main attribute tells Swift exactly where your program starts. iOS launches your app by running the type marked with it.

@main
struct MyFirstApp: App {
}

Conforming to App

Your main struct conforms to the App protocol. This is the SwiftUI blueprint for an application, describing what scenes it shows.

The body Property

Inside the App struct, a body property describes your app's scenes. SwiftUI reads it to know what to display when the app launches.

var body: some Scene {
    WindowGroup {
        ContentView()
    }
}

Scenes, Not Views

The app's body returns a Scene, not a View. A scene is a container for a window or screen that holds your actual views inside it.

WindowGroup

WindowGroup is the most common scene. It manages your app's main window and, on iPhone, simply fills the whole screen.

Your Root View

Inside WindowGroup you place your root view, usually ContentView(). It is the first screen the user sees when the app opens.

ContentView Lives Apart

ContentView sits in its own file, separate from the app file. Keeping the entry point and the UI apart keeps your project tidy and clear.

How It Flows

The chain is simple: @main starts the App, the App shows a WindowGroup, and the WindowGroup displays your ContentView. ✨

One @main Only

An app can have just one @main entry point. The template already provides it, so you rarely add or change this part yourself.

Where You Work

You will spend most of your time editing views like ContentView, not the app file. The app file mostly just wires everything together.

Quick Check

What is the job of the WindowGroup scene in the app file?

Recap

You learned the chain: @main on the App struct returns a WindowGroup scene that shows ContentView. That is how a SwiftUI app boots up. 🧩

よくある質問

「SwiftUI アプリ ファイルの構成」レッスンは無料ですか?

はい。「SwiftUI アプリ ファイルの構成」の完全なテキストはこのウェブで無料で読めます。インタラクティブに演習し(組み込みコードエディタと24時間対応のAIチューター)、SwiftUI Academyコースの残りをアンロックするには、CoddyKit PROにアップグレードしてください。 SwiftUI Academyコースには全4レッスンが含まれています。

「SwiftUI アプリ ファイルの構成」で何を学びますか?

@main、App、WindowGroup、ContentView について理解します。 ブラウザで直接実行するハンズオンコードでSwiftUI Academyを演習し、24時間対応のAIチューターがレッスンを進める中での質問に答えます。

SwiftUI Academyを始めるのに経験は必要ですか?

事前経験は必要ありません。CoddyKitのSwiftUI Academyは初級者から上級者向けに構成されているため、ここから始めるか最初から始めて、自分のペースで進むことができます。 これはレッスン2/4です。

「SwiftUI アプリ ファイルの構成」レッスンにはどのくらい時間がかかりますか?

ほとんどのCoddyKitレッスンは約5~10分かかります。各レッスンはコンパクトでインタラクティブなので、着実に進歩し、ウェブとアプリ全体で正確に前回の場所から再開できます。

このSwiftUI Academyレッスンでコードを書いて実行できますか?

はい。すべてのSwiftUI Academyレッスンに組み込みコードエディタが含まれているため、ブラウザでリアルコードを書いて実行し、即座のAIフィードバックを取得できます。ローカル設定は不要です。

このコースのすべてのレッスン

  1. Xcode のインストールとプロジェクトの作成
  2. SwiftUI アプリ ファイルの構成
  3. ライブプレビュー キャンバス
  4. シミュレーターとデバイスでの実行
← SwiftUI Academyに戻る