批次1: req-prd 瘦身 + req-design 重定位 + dev-coding 聚焦 批次2: dev-review 新建 + review-checklist 插件 批次3: dev-integration 新建 + req-compare 拆出 批次4: 插件完善 (req-research/db-migration/dev-scaffold/deploy-rollback) 批次5: 平台拆分 (dev-ios/dev-android/dev-mcp/dev-pda) + dev 分组更新 批次6: marketplace.json 32→44 plugins Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
91 lines
2.6 KiB
Markdown
91 lines
2.6 KiB
Markdown
---
|
||
name: dev-ios
|
||
description: iOS 开发插件。Swift/SwiftUI + MVVM 架构,TestFlight 部署。当涉及 iOS 开发任务时按需加载。
|
||
---
|
||
|
||
# iOS 开发插件 (dev-ios)
|
||
|
||
## 架构:SwiftUI + MVVM
|
||
|
||
```
|
||
AI-Proj-iOS/
|
||
├── Core/ # 核心层
|
||
│ ├── Architecture/ # AppCoordinator, AppState
|
||
│ ├── Components/ # 通用 UI 组件
|
||
│ ├── Config.swift # 配置
|
||
│ ├── Services/ # APIEndpoints, AuthService, NetworkService, DIContainer
|
||
│ ├── Theme/ # 主题配置
|
||
│ └── Utilities/ # 设备适配
|
||
├── Features/ # 功能模块(MVVM)
|
||
│ └── Requirements/ # 示例:List/Detail View + ViewModel
|
||
├── Models/ # 数据模型 + DTOs
|
||
└── Resources/ # Assets
|
||
```
|
||
|
||
**开发顺序**:Model → DTO → APIEndpoints → ServiceProtocols → ViewModel → View
|
||
|
||
## 代码规范
|
||
|
||
```swift
|
||
@MainActor
|
||
class TaskViewModel: ObservableObject {
|
||
@Published private(set) var tasks: [Task] = []
|
||
@Published private(set) var isLoading = false
|
||
@Published var error: String?
|
||
|
||
private let taskService: TaskServiceProtocol
|
||
|
||
init(taskService: TaskServiceProtocol) {
|
||
self.taskService = taskService
|
||
}
|
||
|
||
func loadTasks() async {
|
||
guard !isLoading else { return }
|
||
isLoading = true
|
||
defer { isLoading = false }
|
||
|
||
do {
|
||
tasks = try await taskService.fetchTasks()
|
||
} catch {
|
||
self.error = error.localizedDescription
|
||
}
|
||
}
|
||
}
|
||
```
|
||
|
||
**规则**:
|
||
- ViewModel 使用 `@MainActor`
|
||
- Published 属性用 `private(set)`
|
||
- 使用协议依赖注入
|
||
- `async/await` 而非 completion handler
|
||
- `guard` 提前返回,`defer` 确保状态重置
|
||
|
||
## 命名规范
|
||
|
||
| 类型 | 规范 | 示例 |
|
||
|------|------|------|
|
||
| 文件/类 | 大驼峰 | `ManualListView.swift` |
|
||
| 协议 | 大驼峰 + Protocol | `ManualServiceProtocol` |
|
||
| 函数/变量 | 小驼峰 | `loadManuals()`, `isLoading` |
|
||
| 枚举 case | 小驼峰 | `case draft` |
|
||
|
||
## 构建与部署
|
||
|
||
```bash
|
||
# 构建
|
||
xcodebuild -scheme AI-Proj-iOS -configuration Debug
|
||
|
||
# 测试
|
||
xcodebuild test -scheme AI-Proj-iOS
|
||
|
||
# TestFlight 部署详见 memory: testflight-deploy.md
|
||
```
|
||
|
||
## 常见问题
|
||
|
||
### SwiftLint 沙盒错误
|
||
Xcode 15+ 默认启用 User Script Sandboxing → Build Settings → `ENABLE_USER_SCRIPT_SANDBOXING = NO`
|
||
|
||
### Personal Team 功能限制
|
||
免费账户不支持 Push Notifications / Associated Domains / App Groups → 从 Entitlements 中移除
|