rules/swift/coding-style.md
This file extends common/coding-style.md with Swift specific content.
swift-format is bundled with Xcode 16+ as an alternativelet over var — define everything as let and only change to var if the compiler requires itstruct with value semantics by default; use class only when identity or reference semantics are neededFollow Apple API Design Guidelines:
static let for constants over global constantsUse typed throws (Swift 6+) and pattern matching:
func load(id: String) throws(LoadError) -> Item {
guard let data = try? read(from: path) else {
throw .fileNotFound(id)
}
return try decode(data)
}
Enable Swift 6 strict concurrency checking. Prefer:
Sendable value types for data crossing isolation boundariesasync let, TaskGroup) over unstructured Task {}