Swift & SwiftUI Coding Standards (Nuance)
Reality Check
- Architecture: The Composable Architecture (TCA) reducers live under
Sources/*Feature. All business logic flows through reducers + effects. - Dependencies:
@Dependency/DependencyValues(seeSources/APIClient,SessionClient, etc.). No shared singletons or Environment injections. - Networking:
Sources/APIClientLiveis regenerated fromopenapi.yamlvia Swift OpenAPI Generator. Uses camelCase operationIds for readable Swift method names. - UI: SwiftUI views backed by
StoreOf<Feature>; UIKit bridges (UIViewRepresentable,UIColorhelpers) exist where required. - Testing: XCTest + TCA
TestStore. SwiftData/Swift Testing/SwiftUI preview patterns in this file are historical and not used. - Builds: WSL-only; all Swift builds/tests occur on GitHub Actions or Xcode Cloud. Use
deploy-prlabel or release tags; never expectxcodebuildlocally.
Pipeline DO/DON'T
| Situation | DO | DON'T |
|---|---|---|
| APIClient/Feature/UI change | Push branch + add deploy-pr label (Xcode Cloud builds/tests). | Run swift build lokalt or start Simulator. |
| Release/version bump | ./scripts/release/prepare.sh + fastlane verify_versions via CI. | Manuelle plist/xcodeproj edits eller Fastlane i WSL. |
| Lint/format | ./scripts/format.sh + BuildTools/SwiftLint via macOS runner. | Installér ikke Swift toolchains i WSL. |
Dependency Injection Pattern
- Define dependencies via
@DependencyClientand access them with@Dependency(\.foo). - Reducers should not instantiate services; rely on dependency values (override-able i tests og previews).
- Views får kun
StoreOf<Feature>ogViewStore; ingen global state mutation.
State Management
- Alle features implementeres som TCA reducers med
@ObservableState. - Lokal SwiftUI-
@Statebruges kun til UI-midlet; alt andet ligger i reduceren. - Brug enum-tilstande for navigation og modalvisninger (se
Destinationenums i features). - Brug
TestStoretil at verificere state transitions + effekter.
Feature Checklist
- Opret nyt
Sources/<FeatureName>/medReducer,State,Action,View. - Deklarér alle eksterne behov via
@Dependency. - Bind SwiftUI view til
StoreOf<Feature>og brug@ViewAction. - Tests:
import ComposableArchitectureTestSupport, brugTestStore. - Pipeline: Push branch + add
deploy-prlabel for Xcode Cloud builds/tests. - Dokumentér nye workflows i
.claude/commandsellerdocs/.
Project Layout (snapshot)
Sources/
├── AppFeature/ # Root reducer + entry point
├── <Feature> # Feature reducers + views
├── APIClient/ # Dependency protocols
├── APIClientLive/ # Generated code + mappings
├── SharedModels/ # Tagged domain models
├── Styleguide/ # Fonts, colors, UI helpers
└── SwiftUIHelpers/ # UIViewRepresentable bridgesTesting Notes
Tests/*FeatureTestsbrugerTestStore. Overrider dependencies med.withDependencies.- Integration builds = Xcode Cloud workflows (
deploy-pr, release tags).
Denne fil beskriver faktisk stack og workflows. For alt omkring pipelines, se også
CLAUDE.mdog.claude/commands/*.