๐ŸŽ

Swift & SwiftUI ๋ชจ๋ฐ”์ผ ์•ฑ ๊ฐœ๋ฐœ ์น˜ํŠธ์‹œํŠธ

Swift 6.x ๋ฐ iOS 18+ ๋Œ€์‘ ์ตœ์‹  ๊ฐ€์ด๋“œ: ํ™˜๊ฒฝ ๊ตฌ์ถ•(Xcode 16+, SPM), ์„ ์–ธํ˜• UI ํ•ต์‹ฌ ๋ฉ˜ํƒˆ ๋ชจ๋ธ, ๋ ˆ์ด์•„์›ƒ ์ปจํ…Œ์ด๋„ˆ(V/H/ZStack, Grid), ๋ชจ๋˜ ์ƒํƒœ ๊ด€๋ฆฌ(iOS 17+ @Observable, @State, @Binding, @Environment), NavigationStack ๋ผ์šฐํŒ…, ์‹ค๋ฌด MVVM ์•„ํ‚คํ…์ฒ˜, Swift 6 Strict Concurrency(async/await) ๋„คํŠธ์›Œํ‚น ๋ฐ ํ”„๋กœ๋•์…˜ ๋ฐฐํฌ ์ฒดํฌ๋ฆฌ์ŠคํŠธ

--views
๋‹จ์ˆ˜:
#swift#swift6#swiftui#ios#macos#mobile#xcode#apple#observable#mvvm#concurrency#async-await#spm์ตœ์ข… ์—…๋ฐ์ดํŠธ: 2026-10-31

1. ์‚ฌ์ „ ์š”๊ฑด & ์‹œ์Šคํ…œ ์š”๊ตฌ์‚ฌ์–‘ (Prerequisites & System Requirements)

๐Ÿ’ป ์‹œ์Šคํ…œ ์„ค์น˜ ๋ฐ ์‹คํ–‰ ์š”๊ตฌ์‚ฌ์–‘ (System Requirements)

ํ•ญ๋ชฉ์ตœ์†Œ ์‚ฌ์–‘ (Minimum)๊ถŒ์žฅ ์‚ฌ์–‘ (Recommended)์ฐธ๊ณ  ๋ฐ ๋น„๊ณ 
์šด์˜์ฒด์ œ (OS)macOS Sonoma 14.5 ์ด์ƒmacOS Sequoia 15.x+ (์ตœ์‹  ์œ ์ง€ ๊ถŒ์žฅ)iOS/iPadOS/macOS ๋„ค์ดํ‹ฐ๋ธŒ ๋นŒ๋“œ์—๋Š” Mac ํ™˜๊ฒฝ ํ•„์ˆ˜
CPUApple Silicon M1 (8์ฝ”์–ด) ๋˜๋Š” Intel Core i7 8์„ธ๋Œ€+Apple Silicon M2 / M3 / M4 Pro/Max (10~14์ฝ”์–ด ์ด์ƒ)Swift ๋งคํฌ๋กœ ํ™•์žฅ ๋ฐ SPM ์˜์กด์„ฑ ๋ณ‘๋ ฌ ์ปดํŒŒ์ผ ๊ฐ€์†
๋ฉ”๋ชจ๋ฆฌ (RAM)16 GB ์ด์ƒ24 GB ~ 36 GB ์ด์ƒ (Apple Silicon ํ†ตํ•ฉ ๋ฉ”๋ชจ๋ฆฌ)Xcode + ์‹œ๋ฎฌ๋ ˆ์ดํ„ฐ(Simulator) + Canvas ์‹ค์‹œ๊ฐ„ ํ”„๋ฆฌ๋ทฐ ๋™์‹œ ๊ตฌ๋™
๋””์Šคํฌ (Storage)40 GB ์ด์ƒ์˜ ์—ฌ์œ  ๊ณต๊ฐ„100 GB ์ด์ƒ์˜ ๊ณ ์† NVMe/SSDXcode ์•ฑ ์ž์ฒด(์•ฝ 30GB40GB) + iOS ๋Ÿฐํƒ€์ž„ ์‹œ๋ฎฌ๋ ˆ์ดํ„ฐ(๊ธฐ๊ธฐ๋‹น 58GB)
๊ฐœ๋ฐœ ๋„๊ตฌ / ๋Ÿฐํƒ€์ž„Xcode 16.0+, Command Line Tools, GitXcode 16.2+, Swift 6.0 / 6.1+, Homebrew, SwiftLintiOS 18+ / macOS 15+ ํƒ€๊นƒ SDK ์ง€์›

๐Ÿ› ๏ธ ๊ฐœ๋ฐœ ํ™˜๊ฒฝ ๊ตฌ์ถ• & CLI ํ•„์ˆ˜ ๋ช…๋ น์–ด

# =============================================================
# 1. Xcode ๋ช…๋ น์ค„ ๋„๊ตฌ(Command Line Tools) ์„ค์น˜ ๋ฐ ํ™•์ธ
# =============================================================
xcode-select --install

# ํ™œ์„ฑํ™”๋œ ๊ฐœ๋ฐœ์ž ๋””๋ ‰ํ„ฐ๋ฆฌ ๊ฒฝ๋กœ ํ™•์ธ (Xcode.app ๋‚ด๋ถ€ ๊ฒฝ๋กœ ์ง€์ • ํ•„์ˆ˜)
xcode-select -p
# /Applications/Xcode.app/Contents/Developer

# ๋งŒ์•ฝ Command Line Tools ๊ฒฝ๋กœ๋กœ ์ž˜๋ชป ์žกํ˜€ ์žˆ๋‹ค๋ฉด ์ „ํ™˜:
sudo xcode-select -s /Applications/Xcode.app/Contents/Developer

# =============================================================
# 2. Swift ์ปดํŒŒ์ผ๋Ÿฌ ๋ฒ„์ „ ๋ฐ ํˆด์ฒด์ธ ํ™•์ธ
# =============================================================
swift --version
# Apple Swift version 6.0 (swiftlang-6.0.0.9.10 clang-1600.0.26.2)
# Target: arm64-apple-macosx15.0

# =============================================================
# 3. ์œ ์šฉํ•œ ๋ณด์กฐ ๋„๊ตฌ ์„ค์น˜ (Homebrew)
# =============================================================
# ์ฝ”๋“œ ์ปจ๋ฒค์…˜ ๋ฆฐํ„ฐ & ํฌ๋งคํ„ฐ
brew install swiftlint
brew install swift-format

# Xcode ๋นŒ๋“œ ๋กœ๊ทธ๋ฅผ ๊น”๋”ํ•˜๊ฒŒ ์ถœ๋ ฅํ•ด์ฃผ๋Š” ๋„๊ตฌ
brew install xcbeautify

# =============================================================
# 4. ์‹œ๋ฎฌ๋ ˆ์ดํ„ฐ ๋ชฉ๋ก ํ™•์ธ ๋ฐ CLI ์‹คํ–‰
# =============================================================
# ์‚ฌ์šฉ ๊ฐ€๋Šฅํ•œ iOS ๋Ÿฐํƒ€์ž„ ๋ฐ ๊ธฐ๊ธฐ UUID ์กฐํšŒ
xcrun simctl list devices available

# ํŠน์ • ์‹œ๋ฎฌ๋ ˆ์ดํ„ฐ ๋ถ€ํŒ… (iPhone 16)
xcrun simctl boot "iPhone 16"

# ์‹œ๋ฎฌ๋ ˆ์ดํ„ฐ GUI ์ฐฝ ๋„์šฐ๊ธฐ
open -a Simulator

2. ํ•ต์‹ฌ ๋ฉ˜ํƒˆ ๋ชจ๋ธ (Declarative UI & Data Flow)

SwiftUI๋Š” ์„ ์–ธํ˜•(Declarative) UI ํ”„๋ ˆ์ž„์›Œํฌ์ž…๋‹ˆ๋‹ค. ๊ฐœ๋ฐœ์ž๊ฐ€ โ€œํ™”๋ฉด์„ ์–ด๋–ป๊ฒŒ ๊ทธ๋ฆด์ง€(How)โ€ ๋ช…๋ นํ•˜๋Š” ๋Œ€์‹ , โ€œํ˜„์žฌ ๋ฐ์ดํ„ฐ ์ƒํƒœ์— ๋”ฐ๋ผ ํ™”๋ฉด์ด ์–ด๋–ป๊ฒŒ ๋ณด์—ฌ์•ผ ํ•˜๋Š”์ง€(What)โ€ ์„ ์–ธํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ”„ ์ƒํƒœ์™€ ๋ทฐ์˜ ๋‹จ๋ฐฉํ–ฅ ๋ฐ์ดํ„ฐ ํ๋ฆ„ (Single Source of Truth)

       +-----------------------------------------------------------+
       |                  ๋ฐ์ดํ„ฐ ์ƒํƒœ (State)                      |
       |  @State, @Binding, @Observable ํด๋ž˜์Šค, @Environment       |
       +-----------------------------+-----------------------------+
                                     โ”‚
                 (1) ์ƒํƒœ ๋ณ€๊ฒฝ ๋ฐœ์ƒ   โ”‚ (2) ๋ณ€๊ฒฝ ๊ตฌ๋… ๋ฐ Diff ์—ฐ์‚ฐ
                                     โ–ผ
       +-----------------------------------------------------------+
       |               SwiftUI View ๊ณ„์ธต (๊ตฌ์กฐ์ฒด Struct)            |
       |   var body: some View { ... } ์ˆœ์ˆ˜ ํ•จ์ˆ˜์ฒ˜๋Ÿผ ํ‰๊ฐ€          |
       +-----------------------------+-----------------------------+
                                     โ”‚
                                     โ–ผ (3) ํ™”๋ฉด ๋ Œ๋”๋ง (UIKit/AppKit ๋„ค์ดํ‹ฐ๋ธŒ ๋ Œ๋”๋Ÿฌ)
       +-----------------------------------------------------------+
       |              ์‚ฌ์šฉ์ž ์ธํ„ฐํŽ˜์ด์Šค (Screen / UI)               |
       |  ์‚ฌ์šฉ์ž ์ƒํ˜ธ์ž‘์šฉ (๋ฒ„ํŠผ ํด๋ฆญ, ํ…์ŠคํŠธ ์ž…๋ ฅ, ์Šค์™€์ดํ”„ ๋“ฑ)    |
       +-----------------------------+-----------------------------+
                                     โ”‚
                                     โ–ผ (4) Action ์ด๋ฒคํŠธ ๋ฐœ์ƒ -> ์ƒํƒœ ๋ณ€๊ฒฝ

๐Ÿ“Š ๋ชจ๋˜ ์ƒํƒœ ๊ด€๋ฆฌ ์–ด๋…ธํ…Œ์ด์…˜ ๋น„๊ต (iOS 17+ ์‹ ๊ทœ ํ‘œ์ค€)

ํ”„๋กœํผํ‹ฐ ๋ž˜ํผ / ๋งคํฌ๋กœํƒ€์ž… ์ข…๋ฅ˜์†Œ์œ ๊ถŒ (Ownership)์ฃผ์š” ์šฉ๋„ ๋ฐ ํŠน์ง•
@State๊ฐ’ ํƒ€์ž… (struct, ๊ธฐ๋ณธํ˜•)๋ทฐ๊ฐ€ ์ง์ ‘ ์†Œ์œ  (Private)ํ•ด๋‹น ๋ทฐ ๋‚ด๋ถ€์—์„œ๋งŒ ์ƒ๋ช…์ฃผ๊ธฐ๋ฅผ ๊ด€๋ฆฌํ•˜๋Š” ๋‹จ์ˆœ ๋กœ์ปฌ UI ์ƒํƒœ
@Binding๊ฐ’ ํƒ€์ž… ์ฐธ์กฐ ์ „๋‹ฌ๋ถ€๋ชจ ๋ทฐ๊ฐ€ ์†Œ์œ ๋ถ€๋ชจ์˜ @State๋ฅผ ์ž์‹ ๋ทฐ๋กœ ์ „๋‹ฌํ•˜์—ฌ ์–‘๋ฐฉํ–ฅ ๋™๊ธฐํ™”
@Observable (์‹ ๊ทœ)์ฐธ์กฐ ํƒ€์ž… (class)์ธ์Šคํ„ด์Šค ์†Œ์œ iOS 17+ ๊ถŒ์žฅ ํ‘œ์ค€. ์†์„ฑ๋ณ„ ์ž๋™ ์˜์กด์„ฑ ์ถ”์ , @Published ๋ถˆํ•„์š”
@Environment์‹œ์Šคํ…œ ๋˜๋Š” ์ปค์Šคํ…€ ๊ฐ์ฒด๋ทฐ ๊ณ„์ธต ์ „์ฒด ๊ณต์œ ๋‹คํฌ๋ชจ๋“œ(colorScheme), ํ™”๋ฉด ๋‹ซ๊ธฐ(dismiss), ์ „์—ญ ์˜์กด์„ฑ ์ฃผ์ž…
ObservableObject (๋ ˆ๊ฑฐ์‹œ)์ฐธ์กฐ ํƒ€์ž… (class ํ”„๋กœํ† ์ฝœ)@StateObject ์†Œ์œ iOS 16 ์ดํ•˜ ํ˜ธํ™˜์šฉ. @Published ์†์„ฑ ๋ณ€๊ฒฝ ์‹œ ๋ทฐ ์ „์ฒด ๋ฌดํšจํ™”

3. [์ดˆ๋ณด์ž 1๋‹จ๊ณ„] ํ—ฌ๋กœ์›”๋“œ / ์ตœ์†Œ ๋™์ž‘ ์˜ˆ์ œ

๋ณต์‚ฌํ•˜์—ฌ Xcode์˜ ContentView.swift ๋˜๋Š” ์‹ ๊ทœ SwiftUI ํ”„๋กœ์ ํŠธ์— ๋ฐ”๋กœ ๋ถ™์—ฌ๋„ฃ์–ด ์‹คํ–‰ํ•  ์ˆ˜ ์žˆ๋Š” ๋…๋ฆฝํ˜• ์™„์ „ ์˜ˆ์ œ์ž…๋‹ˆ๋‹ค.

import SwiftUI

// MARK: - [Step 1] ์•ฑ์˜ ์ง„์ž…์  (App Protocol)
@main
struct HelloWorldApp: App {
    var body: some Scene {
        WindowGroup {
            CounterContentView()
        }
    }
}

// MARK: - [Step 2] ๋ฉ”์ธ ๋ทฐ ๊ตฌํ˜„
struct CounterContentView: View {
    // ๋ทฐ๊ฐ€ ์†Œ์œ ํ•˜๋Š” ๋‹จ์ผ ์ง„์‹ค ๊ณต๊ธ‰์›(Single Source of Truth) ๋กœ์ปฌ ์ƒํƒœ
    @State private var count: Int = 0
    @State private var isLiked: Bool = false
    
    var body: some View {
        VStack(spacing: 24) {
            // ํ—ค๋” ํƒ€์ดํ‹€ ๋ฐ SF Symbols ์•„์ด์ฝ˜
            HStack(spacing: 8) {
                Image(systemName: "apple.logo")
                    .font(.system(size: 32))
                    .foregroundStyle(.primary)
                Text("SwiftUI ์‹œ์ž‘ํ•˜๊ธฐ")
                    .font(.title2)
                    .fontWeight(.bold)
            }
            
            // ์นด์šดํ„ฐ ๋””์Šคํ”Œ๋ ˆ์ด ์นด๋“œ
            VStack(spacing: 12) {
                Text("ํ˜„์žฌ ์นด์šดํŠธ")
                    .font(.subheadline)
                    .foregroundStyle(.secondary)
                
                Text("\(count)")
                    .font(.system(size: 56, weight: .heavy, design: .rounded))
                    .foregroundStyle(count >= 0 ? Color.blue : Color.red)
                    .contentTransition(.numericText()) // ์ˆซ์ž ๋ณ€๊ฒฝ ์‹œ ๋ถ€๋“œ๋Ÿฌ์šด ์• ๋‹ˆ๋ฉ”์ด์…˜
            }
            .frame(maxWidth: .infinity)
            .padding(.vertical, 32)
            .background(Color(.secondarySystemBackground))
            .clipShape(RoundedRectangle(cornerRadius: 16))
            
            // ์ปจํŠธ๋กค ๋ฒ„ํŠผ ์„ธํŠธ
            HStack(spacing: 16) {
                Button(action: {
                    withAnimation(.spring(response: 0.3, dampingFraction: 0.6)) {
                        count -= 1
                    }
                }) {
                    Label("๊ฐ์†Œ", systemImage: "minus.circle.fill")
                        .font(.headline)
                        .frame(maxWidth: .infinity)
                        .padding()
                        .background(Color.red.opacity(0.15))
                        .foregroundStyle(.red)
                        .clipShape(RoundedRectangle(cornerRadius: 12))
                }
                
                Button(action: {
                    withAnimation(.spring(response: 0.3, dampingFraction: 0.6)) {
                        count += 1
                    }
                }) {
                    Label("์ฆ๊ฐ€", systemImage: "plus.circle.fill")
                        .font(.headline)
                        .frame(maxWidth: .infinity)
                        .padding()
                        .background(Color.blue)
                        .foregroundStyle(.white)
                        .clipShape(RoundedRectangle(cornerRadius: 12))
                }
            }
            
            // ํ† ๊ธ€ ๋ฒ„ํŠผ ๋ฐ ์กฐ๊ฑด๋ถ€ ๋ Œ๋”๋ง
            Button(action: {
                withAnimation {
                    isLiked.toggle()
                }
            }) {
                HStack {
                    Image(systemName: isLiked ? "heart.fill" : "heart")
                        .foregroundStyle(isLiked ? .pink : .secondary)
                    Text(isLiked ? "์ฆ๊ฒจ์ฐพ๊ธฐ ๋“ฑ๋ก๋จ" : "์ฆ๊ฒจ์ฐพ๊ธฐ ์ถ”๊ฐ€")
                        .font(.subheadline)
                        .foregroundStyle(isLiked ? .pink : .primary)
                }
                .padding(.horizontal, 16)
                .padding(.vertical, 10)
                .background(isLiked ? Color.pink.opacity(0.12) : Color(.tertiarySystemBackground))
                .clipShape(Capsule())
            }
            
            Spacer()
        }
        .padding(24)
    }
}

// MARK: - [Step 3] Xcode ์‹ค์‹œ๊ฐ„ ์บ”๋ฒ„์Šค ํ”„๋ฆฌ๋ทฐ (iOS 17+ ๋งคํฌ๋กœ)
#Preview("๋ผ์ดํŠธ ๋ชจ๋“œ") {
    CounterContentView()
}

#Preview("๋‹คํฌ ๋ชจ๋“œ") {
    CounterContentView()
        .preferredColorScheme(.dark)
}
[์‹คํ–‰ ๊ฒฐ๊ณผ ์ฝ˜์†” & UI ๋™์ž‘]
1. ํ™”๋ฉด ์ƒ๋‹จ: Apple ๋กœ๊ณ ์™€ ํ•จ๊ป˜ "SwiftUI ์‹œ์ž‘ํ•˜๊ธฐ" ๋ณผ๋“œ ํƒ€์ดํ‹€ ๋ Œ๋”๋ง.
2. ์ค‘์•™ ์นด๋“œ: 56pt ๋ผ์šด๋“œ ๋ณผ๋“œ ํฐํŠธ๋กœ 0 ํ‘œ์‹œ.
3. [์ฆ๊ฐ€] ํƒญ ์‹œ: ์Šคํ”„๋ง ๋ฌผ๋ฆฌ ๋ฐ”์šด์Šค์™€ ํ•จ๊ป˜ ์ˆซ์ž๊ฐ€ 1, 2, 3...์œผ๋กœ ๋ถ€๋“œ๋Ÿฝ๊ฒŒ ์ฆ๊ฐ€.
4. [ํ•˜ํŠธ ๋ฒ„ํŠผ] ํƒญ ์‹œ: ๋ถ„ํ™์ƒ‰ ์ฑ„์›Œ์ง„ ํ•˜ํŠธ๋กœ ์• ๋‹ˆ๋ฉ”์ด์…˜๋˜๋ฉฐ "์ฆ๊ฒจ์ฐพ๊ธฐ ๋“ฑ๋ก๋จ"์œผ๋กœ ์ƒํƒœ ์ฆ‰์‹œ ๋ฐ˜์‘.

4. [2๋‹จ๊ณ„] ํ•ต์‹ฌ ๊ธฐ๋Šฅ ๊ฐ€์ด๋“œ

4.1 ๊ธฐ๋ณธ ๋ ˆ์ด์•„์›ƒ ์ปจํ…Œ์ด๋„ˆ (Stacks & ScrollView)

SwiftUI๋Š” ํฌ๊ฒŒ 3๊ฐ€์ง€์˜ ์„ ํ˜• ์Šคํƒ๊ณผ 2๊ฐ€์ง€ ์ง€์—ฐ ๋กœ๋”ฉ ์ปจํ…Œ์ด๋„ˆ๋ฅผ ๊ธฐ๋ณธ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.

import SwiftUI

struct LayoutDemoView: View {
    let columns = [
        GridItem(.flexible(), spacing: 12),
        GridItem(.flexible(), spacing: 12)
    ]
    
    var body: some View {
        ScrollView(.vertical, showsIndicators: true) {
            VStack(alignment: .leading, spacing: 20) {
                // 1. HStack: ์ˆ˜ํ‰ ์ •๋ ฌ
                HStack(alignment: .center, spacing: 12) {
                    Circle()
                        .fill(Color.orange)
                        .frame(width: 44, height: 44)
                    
                    VStack(alignment: .leading, spacing: 4) {
                        Text("์‚ฌ์šฉ์ž ํ”„๋กœํ•„")
                            .font(.headline)
                        Text("ios_developer@luckytech.com")
                            .font(.caption)
                            .foregroundStyle(.secondary)
                    }
                    
                    Spacer() // ๋‚จ์€ ๊ณต๊ฐ„์„ ๋ฐ€์–ด๋ƒ„
                    
                    Image(systemName: "chevron.right")
                        .foregroundStyle(.tertiary)
                }
                .padding()
                .background(Color(.secondarySystemBackground))
                .clipShape(RoundedRectangle(cornerRadius: 12))
                
                // 2. ZStack: ์•ž๋’ค ๋ ˆ์ด์–ด ์ค‘์ฒฉ (๋ฐฐ๊ฒฝ, ์˜ค๋ฒ„๋ ˆ์ด, ๋ฑƒ์ง€)
                ZStack(alignment: .topTrailing) {
                    RoundedRectangle(cornerRadius: 16)
                        .fill(LinearGradient(
                            colors: [.indigo, .purple],
                            startPoint: .topLeading,
                            endPoint: .bottomTrailing
                        ))
                        .frame(height: 120)
                    
                    // ์šฐ์ธก ์ƒ๋‹จ ๋ฑƒ์ง€ ์˜ค๋ฒ„๋ ˆ์ด
                    Text("PRO")
                        .font(.caption2)
                        .fontWeight(.heavy)
                        .padding(.horizontal, 8)
                        .padding(.vertical, 4)
                        .background(.ultraThinMaterial)
                        .foregroundStyle(.white)
                        .clipShape(Capsule())
                        .padding(12)
                }
                
                // 3. LazyVGrid: 2์—ด ๊ฒฉ์ž ๊ทธ๋ฆฌ๋“œ ๋ ˆ์ด์•„์›ƒ
                Text("์„œ๋น„์Šค ์นดํ…Œ๊ณ ๋ฆฌ")
                    .font(.headline)
                
                LazyVGrid(columns: columns, spacing: 12) {
                    ForEach(1...4, id: \.self) { index in
                        VStack(spacing: 8) {
                            Image(systemName: "cube.fill")
                                .font(.title2)
                                .foregroundStyle(.blue)
                            Text("๋ชจ๋“ˆ \(index)")
                                .font(.subheadline)
                                .fontWeight(.medium)
                        }
                        .frame(maxWidth: .infinity)
                        .padding(.vertical, 20)
                        .background(Color(.tertiarySystemBackground))
                        .clipShape(RoundedRectangle(cornerRadius: 12))
                    }
                }
            }
            .padding()
        }
    }
}

4.2 ๋ทฐ ์ˆ˜์ •์ž(View Modifier) ์ฒด์ด๋‹ ๊ทœ์น™

SwiftUI์—์„œ ์ˆ˜์ •์ž๋Š” ํ˜ธ์ถœ ์ˆœ์„œ๋Œ€๋กœ ๋ทฐ๋ฅผ ์ƒˆ๋กœ์šด ๋ทฐ๋กœ ๋ž˜ํ•‘ํ•˜๋ฏ€๋กœ ์ฒด์ด๋‹ ์ˆœ์„œ๊ฐ€ ๊ฒฐ๊ณผ์— ์ ˆ๋Œ€์ ์ธ ์˜ํ–ฅ์„ ๋ฏธ์นฉ๋‹ˆ๋‹ค.

// โš ๏ธ [์ฃผ์˜] ์ˆ˜์ •์ž ์ˆœ์„œ์— ๋”ฐ๋ฅธ ์™„์ „ํžˆ ๋‹ค๋ฅธ ๋ Œ๋”๋ง ๊ฒฐ๊ณผ
struct ModifierOrderDemo: View {
    var body: some View {
        HStack(spacing: 24) {
            // ์˜ฌ๋ฐ”๋ฅธ ์ˆœ์„œ: ์•ˆ์ชฝ ํŒจ๋”ฉ -> ๋ฐฐ๊ฒฝ์ƒ‰ -> ์™ธ๊ณฝ์„  ํด๋ฆฌํ•‘
            Text("ํŒจ๋”ฉ ํ›„ ๋ฐฐ๊ฒฝ")
                .padding(16)
                .background(Color.green)
                .clipShape(RoundedRectangle(cornerRadius: 10))
                .foregroundStyle(.white)
            
            // ์ž˜๋ชป๋œ ์ˆœ์„œ: ๋ฐฐ๊ฒฝ์ƒ‰์ด ํ…์ŠคํŠธ์—๋งŒ ๋ถ™๊ณ  ๋ฐ”๊นฅ์œผ๋กœ ํŒจ๋”ฉ์ด ์ ์šฉ๋จ
            Text("๋ฐฐ๊ฒฝ ํ›„ ํŒจ๋”ฉ")
                .background(Color.green) // ๊ธ€์ž ์˜์—ญ๋งŒ ์ดˆ๋ก์ƒ‰
                .padding(16)            // ์ดˆ๋ก์ƒ‰ ์˜์—ญ ๋ฐ”๊นฅ์— ์—ฌ๋ฐฑ ์ƒ์„ฑ
                .clipShape(RoundedRectangle(cornerRadius: 10))
                .foregroundStyle(.white)
        }
    }
}

4.3 ๋™์  ๋ชฉ๋ก(List) & ๋ชจ๋˜ ๋ผ์šฐํŒ…(NavigationStack)

iOS 16+๋ถ€ํ„ฐ ๋„์ž…๋œ ํƒ€์ž… ์•ˆ์ „(Type-safe) ๊ฒฝ๋กœ ๊ธฐ๋ฐ˜ NavigationStack์€ ๋Œ€ํ˜• ์•ฑ์˜ ๋”ฅ๋งํฌ ๋ฐ ํ™”๋ฉด ์ด๋™์˜ ํ‘œ์ค€์ž…๋‹ˆ๋‹ค.

import SwiftUI

// ์ด๋™ํ•  ํ™”๋ฉด์˜ ๋Œ€์ƒ ๋ฐ์ดํ„ฐ ๋ชจ๋ธ (Hashable ํ•„์ˆ˜ ๊ตฌํ˜„)
struct TechTopic: Identifiable, Hashable {
    let id = UUID()
    let name: String
    let category: String
    let detailDescription: String
}

struct TopicListView: View {
    @State private var topics: [TechTopic] = [
        TechTopic(name: "Swift 6 Concurrency", category: "Language", detailDescription: "๋ฐ์ดํ„ฐ ๋ ˆ์ด์Šค ์•ˆ์ „์„ฑ์„ ์ปดํŒŒ์ผ ํƒ€์ž„์— ๋ณด์žฅํ•˜๋Š” ๋ชจ๋˜ ๋™์‹œ์„ฑ ๋ชจ๋ธ"),
        TechTopic(name: "SwiftUI Observation", category: "UI", detailDescription: "@Observable ๋งคํฌ๋กœ๋ฅผ ํ†ตํ•œ ์„ธ๋ฐ€ํ•œ ํ”„๋กœํผํ‹ฐ ๋‹จ์œ„ ๋ทฐ ๋ฌดํšจํ™”"),
        TechTopic(name: "Swift Data", category: "Persistence", detailDescription: "Core Data๋ฅผ ๋Œ€์ฒดํ•˜๋Š” ์ˆœ์ˆ˜ Swift ๊ธฐ๋ฐ˜ ๊ฐ์ฒด ์˜์†์„ฑ ํ”„๋ ˆ์ž„์›Œํฌ")
    ]
    
    // ๋„ค๋น„๊ฒŒ์ด์…˜ ๊ฒฝ๋กœ ์Šคํƒ ์ƒํƒœ
    @State private var navigationPath = NavigationPath()
    
    var body: some View {
        NavigationStack(path: $navigationPath) {
            List {
                ForEach(topics) { topic in
                    // ๋ฐ์ดํ„ฐ๋ฅผ ๊ฐ’(Value)์œผ๋กœ ์ „๋‹ฌ
                    NavigationLink(value: topic) {
                        VStack(alignment: .leading, spacing: 4) {
                            Text(topic.name)
                                .font(.headline)
                            Text(topic.category)
                                .font(.caption)
                                .foregroundStyle(.secondary)
                        }
                        .padding(.vertical, 4)
                    }
                    .swipeActions(edge: .trailing, allowsFullSwipe: true) {
                        Button(role: .destructive) {
                            topics.removeAll { $0.id == topic.id }
                        } label: {
                            Label("์‚ญ์ œ", systemImage: "trash")
                        }
                    }
                }
            }
            .navigationTitle("ํ•™์Šต ์ฃผ์ œ ๋ชฉ๋ก")
            // NavigationLink(value:)์˜ ๋ชฉ์ ์ง€ ๋ฐ”์ธ๋”ฉ
            .navigationDestination(for: TechTopic.self) { selectedTopic in
                TopicDetailView(topic: selectedTopic)
            }
            // ๋‹น๊ฒจ์„œ ์ƒˆ๋กœ๊ณ ์นจ (Pull-to-Refresh)
            .refreshable {
                try? await Task.sleep(nanoseconds: 1_000_000_000)
                print("๋ฐ์ดํ„ฐ ๊ฐฑ์‹  ์™„๋ฃŒ")
            }
        }
    }
}

// ์ƒ์„ธ ํ™”๋ฉด
struct TopicDetailView: View {
    let topic: TechTopic
    @Environment(\.dismiss) private var dismiss // ํ™”๋ฉด ๋‹ซ๊ธฐ ํ™˜๊ฒฝ ๋ณ€์ˆ˜
    
    var body: some View {
        VStack(alignment: .leading, spacing: 16) {
            Text(topic.category)
                .font(.caption)
                .fontWeight(.bold)
                .padding(.horizontal, 10)
                .padding(.vertical, 4)
                .background(Color.blue.opacity(0.1))
                .foregroundStyle(.blue)
                .clipShape(Capsule())
            
            Text(topic.name)
                .font(.largeTitle)
                .fontWeight(.bold)
            
            Text(topic.detailDescription)
                .font(.body)
                .foregroundStyle(.secondary)
                .lineSpacing(6)
            
            Spacer()
            
            Button("๋’ค๋กœ ๊ฐ€๊ธฐ") {
                dismiss()
            }
            .frame(maxWidth: .infinity)
            .padding()
            .background(Color(.secondarySystemBackground))
            .clipShape(RoundedRectangle(cornerRadius: 12))
        }
        .padding(20)
        .navigationBarTitleDisplayMode(.inline)
    }
}

4.4 iOS 17+ ์‹ ๊ทœ @Observable ์ƒํƒœ ๊ด€๋ฆฌ ์™„์ „ ์ •๋ณต

๊ธฐ์กด ObservableObject์™€ @Published๋Š” ์†์„ฑ ์ค‘ ํ•˜๋‚˜๋งŒ ๋ณ€๊ฒฝ๋˜์–ด๋„ ๋ทฐ ์ „์ฒด๊ฐ€ ๋‹ค์‹œ ํ‰๊ฐ€๋˜์—ˆ์Šต๋‹ˆ๋‹ค. iOS 17์˜ @Observable ๋งคํฌ๋กœ๋Š” ์‹ค์ œ ๋ทฐ์—์„œ ์ฝ์€(Read) ํŠน์ • ์†์„ฑ๋งŒ์„ ์ถ”์ ํ•˜์—ฌ ์ตœ์†Œํ•œ์˜ ๋ฒ”์œ„๋งŒ ๋ฆฌ๋ Œ๋”๋งํ•ฉ๋‹ˆ๋‹ค.

import SwiftUI
import Observation

// MARK: - [1] ๋น„์ฆˆ๋‹ˆ์Šค ์ƒํƒœ ๋ชจ๋ธ ์ •์˜ (@Observable ๋งคํฌ๋กœ)
@Observable
final class UserProfileModel {
    var username: String = "LuckyDeveloper"
    var isSubscribed: Bool = false
    var notificationCount: Int = 5
    
    func upgradeSubscription() {
        isSubscribed = true
    }
}

// MARK: - [2] ๋ถ€๋ชจ ๋ทฐ (@State๋กœ ์ธ์Šคํ„ด์Šค ์ƒ๋ช…์ฃผ๊ธฐ ๊ด€๋ฆฌ)
struct UserProfileContainerView: View {
    @State private var userModel = UserProfileModel()
    
    var body: some View {
        VStack(spacing: 20) {
            Text("์‚ฌ์šฉ์ž ๊ณ„์ • ์„ผํ„ฐ")
                .font(.title3)
                .fontWeight(.bold)
            
            // ์ž์‹ ์ปดํฌ๋„ŒํŠธ์— ๋ชจ๋ธ ์ง์ ‘ ์ฐธ์กฐ ์ „๋‹ฌ
            ProfileStatusCard(model: userModel)
            
            // ์–‘๋ฐฉํ–ฅ ๋ฐ”์ธ๋”ฉ ์ „๋‹ฌ (@Bindable ์‚ฌ์šฉ)
            ProfileEditForm(model: userModel)
        }
        .padding()
    }
}

// MARK: - [3] ์ฝ๊ธฐ ์ „์šฉ ์ž์‹ ๋ทฐ (ํŠน์ • ์†์„ฑ๋งŒ ๊ด€์ฐฐ)
struct ProfileStatusCard: View {
    let model: UserProfileModel
    
    var body: some View {
        // notificationCount๊ฐ€ ๋ณ€๊ฒฝ๋˜์–ด๋„ isSubscribed๋ฅผ ์ฝ์ง€ ์•Š๋Š” ๋‹ค๋ฅธ ๋ทฐ๋Š” ์žฌ๋ Œ๋”๋ง๋˜์ง€ ์•Š์Œ
        HStack {
            VStack(alignment: .leading, spacing: 4) {
                Text(model.username)
                    .font(.headline)
                Text(model.isSubscribed ? "VIP ํšŒ์›" : "์ผ๋ฐ˜ ํšŒ์›")
                    .font(.caption)
                    .foregroundStyle(model.isSubscribed ? .green : .secondary)
            }
            Spacer()
            if !model.isSubscribed {
                Button("๊ตฌ๋…ํ•˜๊ธฐ") {
                    model.upgradeSubscription()
                }
                .buttonStyle(.borderedProminent)
            }
        }
        .padding()
        .background(Color(.secondarySystemBackground))
        .clipShape(RoundedRectangle(cornerRadius: 12))
    }
}

// MARK: - [4] ์–‘๋ฐฉํ–ฅ ๋ฐ”์ธ๋”ฉ ์ž์‹ ๋ทฐ (@Bindable ํ™œ์šฉ)
struct ProfileEditForm: View {
    // @Observable ํด๋ž˜์Šค์˜ ์†์„ฑ์„ TextField ๋“ฑ์˜ $๋ฐ”์ธ๋”ฉ์œผ๋กœ ๋ณ€ํ™˜ํ•  ๋•Œ ์‚ฌ์šฉ
    @Bindable var model: UserProfileModel
    
    var body: some View {
        VStack(alignment: .leading, spacing: 8) {
            Text("์ด๋ฆ„ ๋ณ€๊ฒฝ")
                .font(.caption)
                .foregroundStyle(.secondary)
            
            TextField("์‚ฌ์šฉ์ž๋ช…์„ ์ž…๋ ฅํ•˜์„ธ์š”", text: $model.username)
                .textFieldStyle(.roundedBorder)
            
            Toggle("ํ”„๋ฆฌ๋ฏธ์—„ ๊ตฌ๋… ํ™œ์„ฑํ™”", isOn: $model.isSubscribed)
                .padding(.top, 8)
        }
        .padding()
        .background(Color(.tertiarySystemBackground))
        .clipShape(RoundedRectangle(cornerRadius: 12))
    }
}

4.5 ๋ชจ๋‹ฌ, ์‹œํŠธ(Sheet) ๋ฐ ์•Œ๋ฆผ์ฐฝ(Alert)

import SwiftUI

struct SheetAlertDemoView: View {
    @State private var isShowingSheet: Bool = false
    @State private var isShowingAlert: Bool = false
    @State private var selectedItemTitle: String = ""
    
    var body: some View {
        VStack(spacing: 16) {
            // 1. ํ•˜๋‹จ ๋ฐ”ํ…€ ์‹œํŠธ (.sheet)
            Button("์„ค์ • ๋ฐ”ํ…€ ์‹œํŠธ ์—ด๊ธฐ") {
                isShowingSheet = true
            }
            .buttonStyle(.borderedProminent)
            .sheet(isPresented: $isShowingSheet) {
                SettingsSheetView()
                    .presentationDetents([.medium, .large]) // iOS 16+ ๋†’์ด ์กฐ์ ˆ
                    .presentationDragIndicator(.visible)
            }
            
            // 2. ์‹œ์Šคํ…œ ํŒ์—… ์•Œ๋ฆผ (.alert)
            Button("๋ฐ์ดํ„ฐ ์ดˆ๊ธฐํ™” ๊ฒฝ๊ณ ") {
                selectedItemTitle = "์บ์‹œ ๋ฐ์ดํ„ฐ"
                isShowingAlert = true
            }
            .buttonStyle(.bordered)
            .tint(.red)
            .alert("์ •๋ง ์‚ญ์ œํ•˜์‹œ๊ฒ ์Šต๋‹ˆ๊นŒ?", isPresented: $isShowingAlert) {
                Button("์ทจ์†Œ", role: .cancel) { }
                Button("์‚ญ์ œ", role: .destructive) {
                    print("\(selectedItemTitle)๊ฐ€ ์‚ญ์ œ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.")
                }
            } message: {
                Text("\(selectedItemTitle) ์‚ญ์ œ ์‹œ ๋ณต๊ตฌํ•  ์ˆ˜ ์—†์Šต๋‹ˆ๋‹ค.")
            }
        }
    }
}

struct SettingsSheetView: View {
    @Environment(\.dismiss) private var dismiss
    
    var body: some View {
        NavigationStack {
            List {
                Section("์•Œ๋ฆผ ์„ค์ •") {
                    Toggle("ํ‘ธ์‹œ ์•Œ๋ฆผ ์ˆ˜์‹ ", isOn: .constant(true))
                }
                Section("๊ณ„์ •") {
                    Text("๋ฒ„์ „ 1.0.0 (Build 2026)")
                }
            }
            .navigationTitle("ํ™˜๊ฒฝ ์„ค์ •")
            .navigationBarTitleDisplayMode(.inline)
            .toolbar {
                ToolbarItem(placement: .topBarTrailing) {
                    Button("์™„๋ฃŒ") {
                        dismiss()
                    }
                }
            }
        }
    }
}

5. [3๋‹จ๊ณ„] ์‹ค๋ฌด ์‘์šฉ ํŒจํ„ด (MVVM & Async Networking)

์‹ค์ œ ํ”„๋กœ๋•์…˜ ์•ฑ์—์„œ ์‚ฌ์šฉํ•˜๋Š” REST API ํ†ต์‹ , Swift Concurrency(async/await), ViewModel ์•„ํ‚คํ…์ฒ˜๋ฅผ ์™„์ „ํžˆ ๊ตฌํ˜„ํ•œ ์ฝ”๋“œ์ž…๋‹ˆ๋‹ค.

5.1 ๋ฐ์ดํ„ฐ ๋ชจ๋ธ ๋ฐ API ๋„คํŠธ์›Œํฌ ์„œ๋น„์Šค ๊ณ„์ธต

import Foundation

// MARK: - [Model] Codable & Identifiable ๋ฐ์ดํ„ฐ ๋ชจ๋ธ
struct PostItem: Identifiable, Codable, Hashable {
    let id: Int
    let title: String
    let body: String
}

// MARK: - [Network Service] ํ†ต์‹  ํ”„๋กœํ† ์ฝœ ๋ฐ ๋น„๋™๊ธฐ ํด๋ผ์ด์–ธํŠธ
protocol PostServiceProtocol: Sendable {
    func fetchPosts() async throws -> [PostItem]
}

final class PostNetworkService: PostServiceProtocol {
    func fetchPosts() async throws -> [PostItem] {
        guard let url = URL(string: "https://jsonplaceholder.typicode.com/posts?_limit=10") else {
            throw URLError(.badURL)
        }
        
        let (data, response) = try await URLSession.shared.data(from: url)
        
        guard let httpResponse = response as? HTTPURLResponse, (200...299).contains(httpResponse.statusCode) else {
            throw URLError(.badServerResponse)
        }
        
        let decoder = JSONDecoder()
        return try decoder.decode([PostItem].self, from: data)
    }
}

5.2 @Observable ViewModel (@MainActor ์Šค๋ ˆ๋“œ ์•ˆ์ „์„ฑ ๋ณด์žฅ)

import SwiftUI
import Observation

// UI ๋ณ€๊ฒฝ์€ ๋ฐ˜๋“œ์‹œ ๋ฉ”์ธ ์Šค๋ ˆ๋“œ์—์„œ ์ผ์–ด๋‚จ์„ ์ปดํŒŒ์ผ๋Ÿฌ ์ˆ˜์ค€์—์„œ ๋ณด์žฅ (@MainActor)
@Observable
@MainActor
final class PostListViewModel {
    // UI ๊ด€์ฐฐ ์ƒํƒœ
    var posts: [PostItem] = []
    var isLoading: Bool = false
    var errorMessage: String? = nil
    
    private let service: PostServiceProtocol
    
    init(service: PostServiceProtocol = PostNetworkService()) {
        self.service = service
    }
    
    func loadPosts() async {
        guard !isLoading else { return }
        
        isLoading = true
        errorMessage = nil
        
        do {
            self.posts = try await service.fetchPosts()
        } catch {
            self.errorMessage = "๋ฐ์ดํ„ฐ๋ฅผ ๋ถˆ๋Ÿฌ์˜ค๋Š” ์ค‘ ์˜ค๋ฅ˜๊ฐ€ ๋ฐœ์ƒํ–ˆ์Šต๋‹ˆ๋‹ค: \(error.localizedDescription)"
        }
        
        isLoading = false
    }
}

5.3 MVVM ๋ทฐ ํ†ตํ•ฉ (.task ์ˆ˜๋ช…์ฃผ๊ธฐ ์—ฐ๋™)

import SwiftUI

struct PostListView: View {
    @State private var viewModel = PostListViewModel()
    
    var body: some View {
        NavigationStack {
            ZStack {
                if viewModel.isLoading && viewModel.posts.isEmpty {
                    // ๋กœ๋”ฉ ์ธ๋””์ผ€์ดํ„ฐ
                    ProgressView("๋„คํŠธ์›Œํฌ ๋ฐ์ดํ„ฐ๋ฅผ ๋ถˆ๋Ÿฌ์˜ค๋Š” ์ค‘...")
                        .scaleEffect(1.2)
                } else if let error = viewModel.errorMessage {
                    // ์—๋Ÿฌ ๋ฐœ์ƒ ์‹œ ์žฌ์‹œ๋„ UI
                    VStack(spacing: 16) {
                        Image(systemName: "exclamationmark.triangle.fill")
                            .font(.system(size: 44))
                            .foregroundStyle(.orange)
                        
                        Text(error)
                            .font(.subheadline)
                            .multilineTextAlignment(.center)
                            .foregroundStyle(.secondary)
                            .padding(.horizontal)
                        
                        Button("๋‹ค์‹œ ์‹œ๋„") {
                            Task {
                                await viewModel.loadPosts()
                            }
                        }
                        .buttonStyle(.borderedProminent)
                    }
                } else {
                    // ์„ฑ๊ณต ๋ชฉ๋ก
                    List(viewModel.posts) { post in
                        VStack(alignment: .leading, spacing: 8) {
                            Text(post.title)
                                .font(.headline)
                                .lineLimit(1)
                            
                            Text(post.body)
                                .font(.caption)
                                .foregroundStyle(.secondary)
                                .lineLimit(2)
                        }
                        .padding(.vertical, 4)
                    }
                    .refreshable {
                        await viewModel.loadPosts()
                    }
                }
            }
            .navigationTitle("์ตœ์‹  ํ”ผ๋“œ (REST API)")
            // ๋ทฐ๊ฐ€ ํ™”๋ฉด์— ๋‚˜ํƒ€๋‚  ๋•Œ ๋น„๋™๊ธฐ ์ž‘์—… ์‹œ์ž‘ ๋ฐ ๋ทฐ ์†Œ๋ฉธ ์‹œ ์ž๋™ ์ทจ์†Œ
            .task {
                await viewModel.loadPosts()
            }
        }
    }
}

6. ์• ๋‹ˆ๋ฉ”์ด์…˜ & ์ œ์Šค์ฒ˜ (Interactive UI)

SwiftUI๋Š” ์ƒํƒœ ๋ณ€๊ฒฝ์„ ์• ๋‹ˆ๋ฉ”์ด์…˜ ๋ธ”๋ก์œผ๋กœ ๊ฐ์‹ธ๊ธฐ๋งŒ ํ•˜๋ฉด ์Šคํ”„๋ง ๋ฌผ๋ฆฌ ๊ธฐ๋ฐ˜ ์ธํ„ฐ๋ž™์…˜์„ ์ฆ‰์‹œ ๋ Œ๋”๋งํ•ฉ๋‹ˆ๋‹ค.

import SwiftUI

struct InteractiveAnimationDemo: View {
    @State private var isExpanded: Bool = false
    @State private var dragOffset: CGSize = .zero
    
    var body: some View {
        VStack(spacing: 32) {
            // 1. ๋“œ๋ž˜๊ทธ ์ œ์Šค์ฒ˜ ๋ฐ ์œ„์น˜ ๋ฆฌ์…‹ ์• ๋‹ˆ๋ฉ”์ด์…˜
            RoundedRectangle(cornerRadius: 20)
                .fill(Color.blue.gradient)
                .frame(width: 140, height: 140)
                .overlay(
                    Text("๋“œ๋ž˜๊ทธ ํ•ด๋ณด์„ธ์š”")
                        .font(.caption)
                        .fontWeight(.bold)
                        .foregroundStyle(.white)
                )
                .offset(dragOffset)
                .gesture(
                    DragGesture()
                        .onChanged { value in
                            dragOffset = value.translation
                        }
                        .onEnded { _ in
                            // ์†์„ ๋—์„ ๋•Œ ํƒ„์„ฑ ์žˆ๊ฒŒ ์ œ์ž๋ฆฌ ๋ณต๊ท€
                            withAnimation(.spring(response: 0.4, dampingFraction: 0.5)) {
                                dragOffset = .zero
                            }
                        }
                )
            
            // 2. ๋†’์ด ํ™•์žฅ ๋ฐ ํšŒ์ „ ์• ๋‹ˆ๋ฉ”์ด์…˜
            VStack {
                HStack {
                    Text("์ƒ์„ธ ์ •๋ณด ์•„์ฝ”๋””์–ธ")
                        .font(.headline)
                    Spacer()
                    Image(systemName: "chevron.down")
                        .rotationEffect(.degrees(isExpanded ? 180 : 0))
                }
                .contentShape(Rectangle())
                .onTapGesture {
                    withAnimation(.easeInOut(duration: 0.3)) {
                        isExpanded.toggle()
                    }
                }
                
                if isExpanded {
                    Text("SwiftUI์˜ ์„ ์–ธํ˜• ์• ๋‹ˆ๋ฉ”์ด์…˜์€ ๋ Œ๋”๋ง ํŒŒ์ดํ”„๋ผ์ธ์—์„œ ๋ณด๊ฐ„(Interpolation)์„ ํ•˜๋“œ์›จ์–ด ๊ฐ€์†์œผ๋กœ ์—ฐ์‚ฐํ•ฉ๋‹ˆ๋‹ค.")
                        .font(.subheadline)
                        .foregroundStyle(.secondary)
                        .padding(.top, 8)
                        .transition(.opacity.combined(with: .move(edge: .top)))
                }
            }
            .padding(16)
            .background(Color(.secondarySystemBackground))
            .clipShape(RoundedRectangle(cornerRadius: 14))
        }
        .padding()
    }
}

7. ์‹ค๋ฌด ์ฃผ์˜์‚ฌํ•ญ & ํ”„๋กœ๋•์…˜ ์ฒดํฌ๋ฆฌ์ŠคํŠธ

โš ๏ธ ์ž์ฃผ ๋ฐœ์ƒํ•˜๋Š” ์‹ค์ˆ˜ & ์•ˆํ‹ฐํŒจํ„ด ๋ฐฉ์ง€

  1. View๊ฐ€ ์™œ ํด๋ž˜์Šค๊ฐ€ ์•„๋‹Œ struct์ธ๊ฐ€์š”?

    • SwiftUI ๋ทฐ๋Š” UIKit์ฒ˜๋Ÿผ ํ™”๋ฉด์— ์žฅ๊ธฐ ์ฒด๋ฅ˜ํ•˜๋Š” ๋ฌด๊ฑฐ์šด ์ธ์Šคํ„ด์Šค๊ฐ€ ์•„๋‹ˆ๋ผ **โ€œ๊ฐ€๋ณ๊ณ  ์ผ์‹œ์ ์ธ ๋ Œ๋”๋ง ๋ช…์„ธ์„œโ€**์ž…๋‹ˆ๋‹ค.
    • ์ƒํƒœ๊ฐ€ ๋ณ€๊ฒฝ๋˜๋ฉด ์ˆ˜์‹ญ ๋ฒˆ ์žฌ์ƒ์„ฑ๋˜๋ฏ€๋กœ, ํž™(Heap) ํ• ๋‹น ๋น„์šฉ์ด ์—†๋Š” **์Šคํƒ(Stack) ๊ธฐ๋ฐ˜ ๊ฐ’ ํƒ€์ž… struct**๋กœ ์„ค๊ณ„๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค.
  2. body ๋‚ด๋ถ€์—์„œ ๋ฌด๊ฑฐ์šด ๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง ์—ฐ์‚ฐ ์ ˆ๋Œ€ ๊ธˆ์ง€

    • body ์†์„ฑ์€ ์ƒํƒœ ๋ณ€๊ฒฝ ์‹œ ์ดˆ๋‹น 60~120ํšŒ ์žฌํ‰๊ฐ€๋  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.
    • ๋‚ ์งœ ํฌ๋งคํŒ…(DateFormatter()), ์ •๋ ฌ(sorted()), ๋Œ€์šฉ๋Ÿ‰ ํ•„ํ„ฐ๋ง ์—ฐ์‚ฐ์€ ViewModel์ด๋‚˜ ์‚ฌ์ „์— ์บ์‹ฑ๋œ ํ”„๋กœํผํ‹ฐ๋กœ ์œ„์ž„ํ•˜์„ธ์š”.
  3. AnyView ๋‚จ์šฉ ๊ธˆ์ง€

    • ๋ฐ˜ํ™˜ ํƒ€์ž…์„ ํ†ต์ผํ•˜๊ธฐ ์œ„ํ•ด AnyView๋กœ ๋ฐ•์‹ฑํ•˜๋ฉด SwiftUI์˜ ๋‚ด๋ถ€ ํƒ€์ž… ํŠธ๋ฆฌ Diffing ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด ๊นจ์ ธ ๋ทฐ ์ „์ฒด๊ฐ€ ๊ฐ•์ œ ์žฌ์ƒ์„ฑ๋ฉ๋‹ˆ๋‹ค.
    • ์กฐ๊ฑด๋ถ€ ๋ถ„๊ธฐ์—๋Š” @ViewBuilder ์–ด๋…ธํ…Œ์ด์…˜์ด๋‚˜ Group์„ ์‚ฌ์šฉํ•˜์„ธ์š”.
  4. ๋น„๋™๊ธฐ ๋ฉ”๋ชจ๋ฆฌ ๋ˆ„์ˆ˜ ๋ฐฉ์ง€

    • onAppear์—์„œ ๋น„๋™๊ธฐ Task.init์„ ์ˆ˜๋™ ์ƒ์„ฑํ•˜์ง€ ๋งˆ์„ธ์š”. ํ™”๋ฉด์„ ๋ฒ—์–ด๋‚˜๋„ ์ทจ์†Œ๋˜์ง€ ์•Š์•„ ๋ฉ”๋ชจ๋ฆฌ ๋ˆ„์ˆ˜๊ฐ€ ๋ฐœ์ƒํ•ฉ๋‹ˆ๋‹ค.
    • ๋ทฐ ์ˆ˜๋ช…์ฃผ๊ธฐ์™€ ์ž๋™์œผ๋กœ ๋ฐ”์ธ๋”ฉ๋˜์–ด ํ™”๋ฉด ์ดํƒˆ ์‹œ ์ž‘์—…์„ ์ž๋™ ์ทจ์†Œํ•˜๋Š” .task { } ์ˆ˜์ •์ž๋ฅผ ์‚ฌ์šฉํ•˜์„ธ์š”.

๐Ÿš€ App Store ๋ฐฐํฌ ํ”„๋กœ๋•์…˜ ์ฒดํฌ๋ฆฌ์ŠคํŠธ

  • Privacy Manifests (PrivacyInfo.xcprivacy): iOS 17+ ํ•„์ˆ˜. ์ถ”์  ๋„๋ฉ”์ธ ๋ฐ ํ•„์ˆ˜ ์„ ์–ธ API(NSPrivacyAccessedAPITypes: ๋””์Šคํฌ ์šฉ๋Ÿ‰, ํƒ€์ž„์Šคํƒฌํ”„ ๋“ฑ)๋ฅผ ๋ˆ„๋ฝ ์—†์ด plist์— ๊ธฐ์žฌํ–ˆ๋Š”์ง€ ์ ๊ฒ€.
  • ๋‹คํฌ ๋ชจ๋“œ & ๋‹ค์ด๋‚ด๋ฏน ํƒ€์ž…(Dynamic Type) ๋Œ€์‘: ํ•˜๋“œ์ฝ”๋”ฉ๋œ ์ƒ‰์ƒ(Color.black) ๋Œ€์‹  Color(.label), .foregroundStyle(.primary) ๋“ฑ ์‹œ๋งจํ‹ฑ ์‹œ์Šคํ…œ ์ปฌ๋Ÿฌ ์‚ฌ์šฉ ํ™•์ธ.
  • ์ธ์ฆ์„œ & ํ”„๋กœ๋น„์ €๋‹ ํ”„๋กœํŒŒ์ผ: App Store Connect ๊ณ„์ •๊ณผ Xcode Signing & Capabilities ์ž๋™ ์„œ๋ช… ์—ฐ๋™.
  • App Icon & ๋Ÿฐ์น˜ ์Šคํฌ๋ฆฐ: 1024x1024 ์‹ฑ๊ธ€ ์‚ฌ์ด์ฆˆ ๋ฒกํ„ฐ Asset ์ ์šฉ ์—ฌ๋ถ€ ์ ๊ฒ€.
  • Swift 6 ๋ชจ๋“œ ๋™์‹œ์„ฑ ๊ฒฝ๊ณ  ์ ๊ฒ€: Xcode Build Settings์˜ Strict Concurrency Checking์„ Complete๋กœ ์„ค์ •ํ•˜์—ฌ ๋ฐ์ดํ„ฐ ๋ ˆ์ด์Šค ์ž ์žฌ ๋ฒ„๊ทธ ์‚ฌ์ „ ์ฐจ๋‹จ.
๐Ÿ’ฌ

์˜๊ฒฌ ๋ฐ ์งˆ๋ฌธ

0
0 / 1500