swift-style-guide
**Archived** Style guide & coding conventions for Swift projects
This is an archived style guide that GitHub's engineering team wrote for writing Swift code. Swift is Apple's programming language used to build iOS, macOS, and related apps. A style guide is a document that explains which of several equivalent ways of writing code a team has agreed to use consistently, so that all code in a project looks and behaves similarly.
The guide is no longer actively maintained, as noted at the top of the README, but the rules it contains reflect decisions that were reasoned through carefully at the time. Each rule includes a rationale explaining why it was chosen.
The rules cover topics like: using tabs rather than spaces for indentation; preferring constants over variables wherever possible so the code is easier to reason about; avoiding a pattern called force-unwrapping that can cause apps to crash; preferring value types (structs) over reference types (classes) in most situations; making classes final by default to avoid unintended inheritance; keeping access control explicit for top-level code; and reducing unnecessary verbosity throughout.
The guide is written for Swift developers who want a reference for how GitHub approached code style decisions, or for teams looking for a starting point for their own Swift coding standards. It is not a tutorial for learning Swift, and it assumes familiarity with the language. Because the repository is archived, the rules reflect a point-in-time snapshot and may not align with current Swift community conventions or later language features.