SwiftUI
Apple's declarative UI framework for iOS, macOS, watchOS, tvOS. Write UI in Swift with a React-like syntax (@State, @Binding). Replaces UIKit/AppKit for new apps. Previews in Xcode. The modern way to build Apple platform apps.
- New Apple platform apps.
- Modern, declarative UI.
- Cross-Apple-platform apps (iOS+macOS+watchOS).
- iOS 12 and older (use UIKit).
- When you need UIKit features not in SwiftUI.
- Non-Apple platforms.
Definition
SwiftUI is a declarative UI framework. Views are structs conforming to View protocol. @State/@Binding for state, @ObservedObject for shared state. Declarative syntax describes UI. Previews in Xcode. Works across all Apple platforms.
Why it exists
UIKit (imperative, storyboards, delegates) was verbose and error-prone. SwiftUI is declarative, reactive, and concise — less code, easier to understand.
How it works
struct MyView: View { var body: some View { ... } }. @State for local state, @Binding for parent-owned state, @ObservedObject/@StateObject for view models. Modifiers chain styling. Xcode canvas previews. NavigationStack for navigation.
Scaling limits
iOS 13+ only (older devices need UIKit). Some features incomplete vs UIKit. Debugging can be tricky. Performance issues with complex layouts. Apple-only.
Cost shape
Free. Requires Xcode (macOS) and Apple Developer Program for App Store.
Alternatives
- UIKit — Mature, imperative, more control, more code.
- React Native/Flutter — Cross-platform, different language.
- Jetpack Compose — Android equivalent, Kotlin.
Failure modes
- iOS 13+ only.
- UIKit feature gaps.
- Debugging complexity.
- Performance on complex layouts.