Files
AFFiNE-Mirror/packages/frontend/apps/ios/AGENTS.md
Lakr 1f228382c2 chore: fix building the app (#13606)
<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

- New Features
  - Built-in Then-style DSL for fluent configuration.
- Centralized theming via a new resources library exposing standardized
colors and icons for SwiftUI and UIKit.

- Refactor
  - Migrated color and icon accessors to the new resources provider.
  - Removed redundant imports and streamlined UI configuration.

- Dependencies
  - Updated MarkdownView to 3.4.2.
- Removed the Then third-party dependency; updated package sources;
added resources package and assets.

- Documentation
  - Added iOS Swift code style and architecture guidelines.

- Chores
  - Updated Xcode project format and repository ignore rules.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
2025-09-19 06:05:05 +00:00

1.5 KiB

Swift Code Style Guidelines

Core Style

  • Indentation: 2 spaces
  • Braces: Opening brace on same line
  • Spacing: Single space around operators and commas
  • Naming: PascalCase for types, camelCase for properties/methods

File Organization

  • Logical directory grouping
  • PascalCase files for types, + for extensions
  • Modular design with extensions

Modern Swift Features

  • @Observable macro: Replace ObservableObject/@Published
  • Swift concurrency: async/await, Task, actor, @MainActor
  • Result builders: Declarative APIs
  • Property wrappers: Use line breaks for long declarations
  • Opaque types: some for protocol returns

Code Structure

  • Early returns to reduce nesting
  • Guard statements for optional unwrapping
  • Single responsibility per type/extension
  • Value types over reference types

Error Handling

  • Result enum for typed errors
  • throws/try for propagation
  • Optional chaining with guard let/if let
  • Typed error definitions

Architecture

  • Protocol-oriented design
  • Dependency injection over singletons
  • Composition over inheritance
  • Factory/Repository patterns

Debug Assertions

  • Use assert() for development-time invariant checking
  • Use assertionFailure() for unreachable code paths
  • Assertions removed in release builds for performance
  • Precondition checking with precondition() for fatal errors

Memory Management

  • weak references for cycles
  • unowned when guaranteed non-nil
  • Capture lists in closures
  • deinit for cleanup