Swift 代码规范(apps/macos)

1. 工具链

2. 目录

apps/macos/
├── Package.swift
├── Info.plist                 应用包的 plist,根目录 build.sh 拷贝进 Yumu.app
└── Sources/
    ├── CGrain/                系统库目标:module.modulemap + 指向 heartwood 的 grain.h 符号链接
    └── Yumu/
        ├── YumuApp.swift      入口与窗口
        ├── Grain/             GrainClient(唯一碰 C 接口的地方)与 Codable 模型
        ├── Bark/              L() 翻译助手、动效助手,Tokens.generated.swift 由 bark/codegen 生成
        ├── Core/              AppModel:跨界面的状态与事件处理
        ├── Features/<Feature>/ 各界面的 View
        └── Resources/         <locale>.lproj/Localizable.strings,由 bark/i18n/build.py 生成

依赖方向:Features → Core → Grain、Bark。Feature 之间不互相依赖,需要通信经由 Core。

3. 架构模式

4. 并发

5. 命名

6. 文案与本地化

7. 设计令牌与动效

8. 测试

9. 禁止事项

源文件 docs/coding-standards/swift.md 更新于 2026-10-08