Swift is a general-purpose compiled language open-sourced by Apple in 2014. It targets Apple operating systems, Linux servers (niche), and cross-platform packages via Swift Package Manager.
Core characteristics
- Static typing with inference —
let count = 10infersInt; types checked at compile time - Optionals —
String?models missing values explicitly instead of null pointer crashes - Value types — structs and enums are copied by default; classes use reference semantics with ARC
- Protocol-oriented design — behavior shared via protocols and extensions, not deep inheritance
Typical build-run flow (local)
- Write
main.swiftwith top-level code or@main swiftc main.swift -o app && ./appor open an Xcode project- Ship via App Store, TestFlight, or CLI distribution on macOS
Important interview questions and answers
- Q: Is Swift garbage collected?
A: No—Swift uses Automatic Reference Counting (ARC) for heap objects; value types live on the stack or inline without reference counting. - Q: Who uses Swift in production?
A: iOS/macOS app teams, Apple first-party software, and some server-side Swift on Linux.
Self-check
- What file extension do Swift sources use?
- Name one major platform where Swift is the default language.
Tip: Swift source uses .swift files compiled with swiftc—think iOS, macOS, and SPM packages.
Interview prep
- Is Swift garbage collected?
No—Swift uses ARC for class instances; structs and enums are value types without reference counting.
- Who uses Swift?
iOS/macOS app teams, Apple first-party software, and niche server-side Swift on Linux.