SwiftUI is Apple’s declarative UI framework—views as structs, state-driven updates, and previews in Xcode. This track stays CLI-focused; full SwiftUI requires Xcode, simulators, and the SwiftUI framework not available in the sandbox.
What SwiftUI adds
@State,@Binding,@Observablefor UI state- Composable views with modifiers (
.padding(),.background()) - Cross-platform UI for iOS, macOS, watchOS, tvOS with conditional compilation
- Previews for rapid iteration without full simulator launches
Compared to other UI stacks
Web UI lives in JavaScript frameworks; Android uses Jetpack Compose in Kotlin. SwiftUI is the Apple-native declarative path.
Important interview questions and answers
- Q: SwiftUI vs UIKit?
A: SwiftUI is declarative and state-driven; UIKit is imperative and mature—many apps combine both during migration. - Q: Can you run SwiftUI in this playground?
A: No—needs SwiftUI imports and Xcode previews; practice locally with a new SwiftUI App template.
Self-check
- Name one SwiftUI state property wrapper.
- What IDE feature shows live UI without running the full app?
Tip: Full SwiftUI needs Xcode—playground stays CLI main.swift without SwiftUI imports.
Interview prep
- SwiftUI vs UIKit?
SwiftUI declarative; UIKit imperative—migration often mixes both.
- Run SwiftUI here?
No—needs SwiftUI framework and Xcode previews.