Files
ai-proj-helper/skills-dev/dev-ios-plugin/skills/SKILL.md
T
johnQ d5bdfcfb7c refactor(skill): 18 个命令型技能转 user-invoked,压目录预算
- biz-* 4 个、integration-* 8 个、dev-android/ios/pda、publish、ai-proj-cicd-release、ai-proj-macos-release
- 均加 metadata.invocation: user-invoked + disable-model-invocation: true(DSH 实测生效)
- catalog: promoted/model-invoked 40、promoted/user-invoked 18、beta 3
2026-10-31 22:16:39 +08:00

94 lines
2.7 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
name: dev-ios
description: iOS 开发插件。Swift/SwiftUI + MVVM 架构,TestFlight 部署。当涉及 iOS 开发任务时按需加载。
metadata:
invocation: user-invoked
disable-model-invocation: true
---
# 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 中移除