Swift Coding Standards

Using Swift

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.


Musts

Native Swift Types

Swift Collection Types

Class Prefixes

Optionals

Force Unwrapping

if let Pyramid of Doom

Unwrapping Multiple Optionals

Error Handling

Forced-try Expression

Let vs. Var

Access Control

Spacing

Closures

Shorthand Argument Syntax

Capture lists

Protocols

Protocol Conformance

Delegate Protocols

Arrays and Dictionaries

Type Shorthand Syntax

Trailing Comma

Constants

Function Parameters

Semicolons

Typealiases

Flow Control

Switch Statements

Use Implicit Getters

Loops

Shoulds

Declaring Variables

Optionals

guard let vs. if let

Spacing

Usage of self

Loops

Closures

Trailing Closure Syntax

Operator Overloading + Custom Operators

Tuples

Constants

Default Initializers

Classes vs Structs

Tips & Tricks

Simplify Xcode's Autocompletion Suggestions