Code Style
Tools
.swiftlint.yml and .swiftformat are the source of truth. When in doubt, check those files.
Formatting
Naming
Access Control
Always explicit. Prefer the most restrictive level that works.Imports
System frameworks first (alphabetical), then third-party, then local. Blank line after imports.Safety
No force unwrapping (!) or force casting (as!). Use guard let, if let, as?.
Logging
OSLog only. Neverprint().
Localization
String(localized:)for user-facing strings in computed properties, AppKit code, alerts, error descriptions- SwiftUI view literals (
Text("Save"),Button("Cancel")) auto-localize - Do not localize technical terms: font names, database types, SQL keywords, encoding names
- Never use
String(localized:)with string interpolation. UseString(format: String(localized: "Preview %@"), name)instead.
SwiftUI Patterns
@Statefor local view state@Observablefor viewmodels (Swift 5.9+)- Property wrapper order: Environment, State, Binding, regular properties
- Extract large views into subviews
Limits
When approaching these limits, extract into extension files:
MainContentCoordinator.swift
Extensions
MainContentCoordinator+RowOperations.swift
MainContentCoordinator+Pagination.swift
MainContentCoordinator+Filtering.swift
