Swift Language Style Conventions Capitalization

30% OFF - 9th Anniversary discount on Entity Framework Extensions until December 15 with code: ZZZANNIVERSARY9


Types & Protocols

Type and protocol names should start with an uppercase letter.


protocol Collection {}
struct String {}
class UIView {}
struct Int {}
enum Color {}

Everything else...

Variables, constants, functions and enumeration cases should start with a lowercase letter.


let greeting = "Hello"
let height = 42.0

enum Color {
    case red
    case green
    case blue

func print(_ string: String) {

Camel Case:

All naming should use the appropriate camel case. Upper camel case for type/protocol names and lower camel case for everything else.

Upper Camel Case:

protocol IteratorType { ... }

Lower Camel Case:

let inputView = ...


Abbreviations should be avoided unless commonly used (e.g. URL, ID). If an abbreviation is used, all letters should have the same case.


let userID: UserID = ...
let urlString: URLString = ...

Got any Swift Language Question?