Swift Coding Standards

Using Swift

Table of Contents

When In Doubt

If questions aren't addressed here refer to the style guides of GitHub, raywenderlich.com, and Apple. If there are inconsistencies, our own standards take precedence. We're at the mercy of a cruel and capricious language unless you, the Vokal iOS Engineer, open a pull request.

Native Swift Types

Swift Collection Types

Class Prefixes

Optionals

Force Unwrapping

if let Pyramid of Doom

guard let vs. if let

Unwrapping Multiple Optionals

Operator Overloading + Custom Operators

Error Handling

Forced-try Expression

Usage of self

Let vs. Var

Access Control

Spacing

Closures

Shorthand Argument Syntax

Trailing Closure Syntax

Capture lists

Simplify Xcode's Autocompletion Suggestions

Protocols

Protocol Conformance

Delegate Protocols

Arrays and Dictionaries

Type Shorthand Syntax

Trailing Comma

Constants

Constants Files

Function Parameters

Semicolons

Declaring Variables

Typealiases

Flow Control

Switch Statements

Use Implicit Getters

Loops

Default Initializers

Tuples