What is SwiftUI?

Answer

SwiftUI is Apple's modern declarative UI framework announced in 2019, available on all Apple platforms (iOS 13+, macOS 10.15+, watchOS 6+, tvOS 13+). It replaces UIKit's imperative approach with a functional, declarative style where you describe WHAT the UI should look like based on state, not HOW to update it step by step. Core concepts: (1) View protocol: the building block. Any struct conforming to View with a body property is a view: struct ContentView: View { var body: some View { VStack { Text("Hello, World!").font(.title) Button("Tap me") { print("Tapped") } } } }; (2) State management: @State (local mutable state), @Binding (two-way binding), @StateObject/@ObservedObject/@EnvironmentObject (reference types), @Environment (app-level values); (3) Declarative updates: when state changes, SwiftUI re-renders the view body automatically — no manual UI updates; (4) Previews: Xcode live previews show UI instantly as you type. Common views: Text, Image, Button, TextField, Toggle, Slider, List, ScrollView, NavigationView/NavigationStack, TabView, VStack, HStack, ZStack, Spacer, Divider. Modifiers: chain to customize views — .font(), .foregroundColor(), .padding(), .background(), .cornerRadius(), .shadow(). SwiftUI vs UIKit: SwiftUI = less code, cross-platform, live previews, modern; UIKit = more control, larger API surface, mature, required for some advanced features. Interoperability: UIViewRepresentable / UIViewControllerRepresentable.