35MM.COFFEEa site built for app makers
Profile
limboy

17 天前

经过几天调研,目前对这个 Xcode 目录结构比较满意。

  • 每一个目录职责清晰。
  • 尽量保证 co-location。
  • Shared 部分为独立、会被多处引用、支持性的模块。
  • Shared 部分稳定后可以单独拿出来作为 Package。
text
AppName/
├─ Configuration/
│  ├─ Info.plist
│  ├─ AppName.entitlements
├─ App/
│  ├─ AppNameApp.swift
│  ├─ AppDelegate.swift           # optional
│  ├─ AppEnvironment.swift        # DI entry points (protocols, factories)
│  └─ Routes.swift                # navigation enums/paths
├─ Features/
│  ├─ Home/
│  │  ├─ Views/
│  │  │  ├─ HomeView.swift
│  │  │  └─ Cells/
│  │  ├─ ViewModels/
│  │  │  └─ HomeViewModel.swift
│  ├─ Auth/
│  │  └─ … (same pattern)
│  └─ ProductDetail/
│     └─ …
├─ Shared/
│  ├─ DesignSystem/
│  │  ├─ Components/              # reusable SwiftUI components
│  │  ├─ Typography.swift
│  │  └─ Theme.swift
│  ├─ Extensions/
│  ├─ Networking/
│  │  ├─ APIClient.swift          # protocol + live/mock
│  │  ├─ Endpoints.swift
│  │  └─ Decoding.swift
│  ├─ Persistence/
│  │  ├─ Database.swift           # SwiftData/CoreData/GRDB facade
│  │  └─ Migrations/
│  ├─ Utils/
│  │  ├─ ImageLoader.swift
│  │  └─ Logger.swift
│  ├─ Views/                      # reusable views like tweet list
├─ Resources/
│  ├─ Assets.xcassets
│  ├─ Localizations/              # .strings, .stringsdict
│  └─ Media/
└─ Scripts/                       # SwiftLint, SwiftFormat, build helpers
maxOS

maxOS

10 天前

想起了 Clean Architecture for SwiftUI: https://blog.stackademic.com/the-clean-architecture-with-mvvm-in-the-ios-swiftui-project-05dd8fe9ec7a

https://github.com/nalexn/clean-architecture-swiftui?tab=readme-ov-file

limboy

limboy

10 天前

嗯,这个也是很经典的架构