Skip to content

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 (see Sources/APIClient, SessionClient, etc.). No shared singletons or Environment injections.
  • Networking: Sources/APIClientLive is regenerated from openapi.yaml via Swift OpenAPI Generator. Uses camelCase operationIds for readable Swift method names.
  • UI: SwiftUI views backed by StoreOf<Feature>; UIKit bridges (UIViewRepresentable, UIColor helpers) 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-pr label or release tags; never expect xcodebuild locally.

Pipeline DO/DON'T

SituationDODON'T
APIClient/Feature/UI changePush 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 @DependencyClient and 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> og ViewStore; ingen global state mutation.

State Management

  • Alle features implementeres som TCA reducers med @ObservableState.
  • Lokal SwiftUI-@State bruges kun til UI-midlet; alt andet ligger i reduceren.
  • Brug enum-tilstande for navigation og modalvisninger (se Destination enums i features).
  • Brug TestStore til at verificere state transitions + effekter.

Feature Checklist

  1. Opret nyt Sources/<FeatureName>/ med Reducer, State, Action, View.
  2. Deklarér alle eksterne behov via @Dependency.
  3. Bind SwiftUI view til StoreOf<Feature> og brug @ViewAction.
  4. Tests: import ComposableArchitectureTestSupport, brug TestStore.
  5. Pipeline: Push branch + add deploy-pr label for Xcode Cloud builds/tests.
  6. Dokumentér nye workflows i .claude/commands eller docs/.

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 bridges

Testing Notes

  • Tests/*FeatureTests bruger TestStore. 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.md og .claude/commands/*.

AI-first documentation for Nuance iOS