British Swift Syntax đŹđ§
If youâve ever winced at the sight of Color instead of Colour, or felt despair reading tryâŚcatch when a good old âWould you mindâŚ?â would be spot on, then this oneâs for you.
Iâve put together a small, but fit and proper set of Swift tidbits that clean up the more questionable Americanisms in our lovely codebases. Itâs a tiny rebellion. A syntax protest. A quiet sip of tea in the face of UIColor.
đ British Swift Gist on GitHub
Brief & Intent
- Inject more charm and gentleness into Swift syntax.
- Reclaim âuâ in
Colour, make error handling more civil, and soften control flow language. - Let code read more like a conversation than a demand.
Approach
đŤ Colour.swift â Because we spell it with a u
typealias Colour = Color
static let systemMint = Colour(UIColor.systemMint)
Every time you write Colour, youâre sticking it to the red-white-and-blue spelling checker. This file maps common UIColor values to Colour for use in SwiftUI and UIKit alike.
đ¤ Perhaps.swift â A gentler if/else
perhaps(isRaining) {
print("Donât forget your umbrella!")
} otherwise: {
print("Looks like a cloudy day. Stay cozy indoors!")
}
Control flow with a soft touch. No more harsh if statements. Just polite suggestions.
Try this:
wouldYouMind {
   try doSomethingRisky()
} actuallyIdoMind: { error in
   print("Actually, I do mind: \(error.localizedDescription)")
}
Because nothing says âunexpected runtime failureâ like pretending youâre fine with it until youâre not.
Why?
Letâs be honest: Americanisms are the base of code syntax and are everywhere, and fair play to them - itâs Appleâs language after all. But if youâre from the UK (or just a fan of proper and not simplified English), these little tweaks make your project feel moreâŚÂ you.
Plus, your code starts to read like a conversation rather than a set of instructions barked at a compiler.
Install
No Cocoapods, no SPM. Just drop or outright copy the .swift files into your project and start writing Swift with a cuppa in hand.
Youâll find:
⢠Colour.swift â For system colours with a u
⢠Perhaps.swift â If/else, but softer
⢠WouldYouMind.swift â Error handling, politely
Grab them here:
đ British Swift Gists â GitHub
Future plans
Iâm toying with the idea of adding whilst, shallWe, and ohDear. Maybe even haveAQuickLookAt.
Let me know if youâve got any ideas or want to collaborate on a Swift Package that brings proper British values to modern codebases. We could call it BritKit or SwiftTea.