swift
What is a .swift file?
text/x-swift
Swift (.swift) is a plain-text source file for the Swift programming language — a statically typed, compiled language from Apple used for iOS, macOS, and server development. It emphasises safety with optionals and value types, and features structs, protocols, generics, and pattern matching.
How to use a .swift file
Use an example .swift file to test syntax highlighters, the Swift compiler, linters and formatters (SwiftLint, swift-format), and parser or language-detection tooling.
Download example .swift files
- Swift — Hello WorldThe classic hello-world in Swift — a single print — for testing highlighters, the Swift compiler, and parsers.
- Swift — Task list (struct, protocol, optionals)A realistic Swift snippet with an enum, a protocol, a struct with a computed property, optionals and optional binding, and higher-order functions — for testing highlighters, the Swift compiler, SwiftLint, and parsers.