Dev Skill - SwiftUI iOS Development Generator
Overview
This skill transforms Product Requirements Documents (PRD) into fully functional SwiftUI iOS applications. It analyzes PRD requirements and generates production-ready code with proper architecture, UI components, data models, and business logic.
Architecture Pattern
MVVM Architecture
All generated code follows the Model-View-ViewModel pattern:
Model Layer
- - Data models (structs conforming to Codable)
- Data persistence (Core Data or SwiftData)
- Network layer (URLSession or Alamofire)
ViewModel Layer
- - Business logic and state management
- Data transformation and validation
- Service coordination
View Layer
- - SwiftUI views with proper componentization
- Navigation stack management
- UI state binding
Code Generation Workflow
1. PRD Analysis
- - Parse PRD document for functional requirements
- Extract screen specifications and user flows
- Identify data models and relationships
- Determine required third-party integrations
2. Project Structure Generation
Create a complete Xcode project with:
CODEBLOCK0
3. Core Components Generation
3.1 Data Models
CODEBLOCK1
3.2 ViewModels
CODEBLOCK2
3.3 SwiftUI Views
CODEBLOCK3
4. Feature Implementation
4.1 Navigation
- - TabView for main navigation
- NavigationStack for hierarchical navigation
- Sheet presentations for modal views
4.2 Data Persistence
- - Core Data for complex relationships
- @AppStorage for simple preferences
- FileManager for document storage
4.3 Networking
- - Async/Await for modern API calls
- Error handling with Result type
- JSON decoding with Codable
4.4 UI/UX
- - Adaptive layout for all device sizes
- Dark mode support
- Accessibility features
- Haptic feedback
Example: Todo App from PRD
PRD Input: Todo app with categories, reminders, sharing
Generated Code:
- 1. Models: Task, Category, Reminder
- ViewModels: TaskListViewModel, CategoryViewModel
- Views: TaskListView, CategoryView, AddTaskView, SettingsView
- Services: NotificationService, SharingService
- Features:
- Push notifications for reminders
- Share sheet integration
- iCloud sync for data
- Widgets for quick access
Auto-Trigger Next Steps
After generating the iOS project, this skill automatically:
- 1. Creates a complete Xcode project in
dev-output/ directory - Verifies code compiles without errors
- Triggers
qa-skill with the generated code as input - Provides build instructions and next steps
Integration Requirements
Input Format
- - PRD markdown document from INLINECODE2
- Structured requirements with priorities
- Technical specifications and constraints
Output Validation
- - All code must compile in Xcode 15+
- Follows SwiftUI best practices
- Includes proper error handling
- Supports iOS 16+ deployment target
Quality Standards
- - 100% SwiftUI (no UIKit unless absolutely necessary)
- Proper separation of concerns
- Comprehensive documentation
- Follows Apple's Human Interface Guidelines
Dev Skill - SwiftUI iOS 开发生成器
概述
此技能将产品需求文档(PRD)转化为功能完整的 SwiftUI iOS 应用程序。它分析 PRD 需求,并生成具有适当架构、UI 组件、数据模型和业务逻辑的生产就绪代码。
架构模式
MVVM 架构
所有生成的代码遵循 Model-View-ViewModel 模式:
模型层
- - 数据模型(遵循 Codable 的结构体)
- 数据持久化(Core Data 或 SwiftData)
- 网络层(URLSession 或 Alamofire)
ViewModel 层
视图层
- - 具有适当组件化的 SwiftUI 视图
- 导航栈管理
- UI 状态绑定
代码生成工作流
1. PRD 分析
- - 解析 PRD 文档以获取功能需求
- 提取屏幕规格和用户流程
- 识别数据模型及其关系
- 确定所需的第三方集成
2. 项目结构生成
创建一个完整的 Xcode 项目,结构如下:
ProjectName/
├── ProjectName.xcodeproj
├── ProjectName/
│ ├── Models/
│ │ ├── DataModel.swift
│ │ └── APIModels.swift
│ ├── ViewModels/
│ │ ├── MainViewModel.swift
│ │ └── [Feature]ViewModel.swift
│ ├── Views/
│ │ ├── ContentView.swift
│ │ ├── [Feature]View.swift
│ │ └── Components/
│ │ ├── ButtonStyles.swift
│ │ └── CustomViews.swift
│ ├── Services/
│ │ ├── APIService.swift
│ │ └── DataService.swift
│ └── Utilities/
│ ├── Extensions.swift
│ └── Constants.swift
└── ProjectNameTests/
└── [Feature]Tests.swift
3. 核心组件生成
3.1 数据模型
swift
struct Task: Identifiable, Codable {
let id: UUID
var title: String
var isCompleted: Bool
var dueDate: Date?
var category: String
var priority: Priority
}
enum Priority: String, Codable, CaseIterable {
case low, medium, high
}
3.2 ViewModels
swift
class TaskViewModel: ObservableObject {
@Published var tasks: [Task] = []
@Published var selectedCategory: String?
private let dataService: DataService
init(dataService: DataService = .shared) {
self.dataService = dataService
loadTasks()
}
func addTask(_ task: Task) { ... }
func deleteTask(_ task: Task) { ... }
func toggleCompletion(_ task: Task) { ... }
}
3.3 SwiftUI 视图
swift
struct TaskListView: View {
@StateObject private var viewModel = TaskViewModel()
@State private var showingAddTask = false
var body: some View {
NavigationView {
List {
ForEach(viewModel.tasks) { task in
TaskRowView(task: task)
}
.onDelete(perform: deleteTask)
}
.navigationTitle(Tasks)
.toolbar {
Button(action: { showingAddTask = true }) {
Image(systemName: plus)
}
}
.sheet(isPresented: $showingAddTask) {
AddTaskView()
}
}
}
}
4. 功能实现
4.1 导航
- - 主导航使用 TabView
- 层级导航使用 NavigationStack
- 模态视图使用 Sheet 呈现
4.2 数据持久化
- - 复杂关系使用 Core Data
- 简单偏好设置使用 @AppStorage
- 文档存储使用 FileManager
4.3 网络通信
- - 现代 API 调用使用 Async/Await
- 使用 Result 类型进行错误处理
- 使用 Codable 进行 JSON 解码
4.4 UI/UX
- - 适配所有设备尺寸的自适应布局
- 深色模式支持
- 无障碍功能
- 触觉反馈
示例:从 PRD 生成待办事项应用
PRD 输入: 具有分类、提醒和共享功能的待办事项应用
生成的代码:
- 1. 模型:Task、Category、Reminder
- ViewModels:TaskListViewModel、CategoryViewModel
- 视图:TaskListView、CategoryView、AddTaskView、SettingsView
- 服务:NotificationService、SharingService
- 功能:
- 提醒的推送通知
- 共享表单集成
- 数据 iCloud 同步
- 快速访问的小组件
自动触发后续步骤
生成 iOS 项目后,此技能会自动:
- 1. 在 dev-output/ 目录中创建一个完整的 Xcode 项目
- 验证代码编译无错误
- 以生成的代码作为输入触发 qa-skill
- 提供构建说明和后续步骤
集成要求
输入格式
- - 来自 prd-skill 的 PRD Markdown 文档
- 带有优先级的结构化需求
- 技术规格和约束条件
输出验证
- - 所有代码必须在 Xcode 15+ 中编译通过
- 遵循 SwiftUI 最佳实践
- 包含适当的错误处理
- 支持 iOS 16+ 部署目标
质量标准
- - 100% SwiftUI(除非绝对必要,否则不使用 UIKit)
- 适当的关注点分离
- 全面的文档
- 遵循苹果人机界面指南