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.
You can find the code featured in this article in full on GitHub here:
š https://gist.github.com/SandorUK/c4d0d094ffb8adc32316a70053e1accf
Letās have a butcher’s, shall we?
š« Colour.swift – Because we spell it with a u
typealias Colour = Color
Thatās it. This puts things right. Every time you write Colour, youāre sticking it to the red-white-and-blue spelling checker.
But I didnāt stop there. This file goes full spectrum on UIKitās colours too, mapping UIColor.systemRed and friends into the Colour type with proper SwiftUI integration:
static let systemMint = Colour(UIColor.systemMint)
All in properly titled British spelling. Because independence was a mistake.
š¤ Perhaps.swift – A gentler, more polite if
Why must control flow be so insisting? So abrupt? Enter perhaps.
perhaps(isRaining) {
print("Donāt forget your umbrella!")
} otherwise: {
print("Looks like a cloudy day. Stay cozy indoors!")
}
A gentle suggestion, not a cold demand. And none of that if this or else that, that, frankly, sounds like a threat.
š WouldYouMind.swift – Swift error handling with manners
Instead of this:
do {
try something()
} catch {
handle(error)
}
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.