← スキル一覧に戻る

ios-architecture
by nguyennamkkb
⭐ 0🍴 0📅 2026年1月9日
SKILL.md
name: ios-architecture description: SwiftUI project structure. Use when creating new projects, new features, new screens, file placement, file naming, folder organization, code refactoring, ViewModel separation, standard directory structure, MVVM, Clean Architecture. allowed-tools: Read, Grep, Glob, Bash
SwiftUI MVVM Structure
Table of Contents
- 1. Directory Structure ... L15-L40
- 2. Naming Conventions ..... L42-L80
- 3. Organization Rules ..... L82-L110
- 4. Feature Example ........... L112-L140
1. Directory Structure
ProjectName/
├── App/
│ └── ProjectNameApp.swift
├── Core/
│ ├── Extensions/
│ ├── Utilities/
│ └── Network/
├── Features/
│ └── FeatureName/
│ ├── Views/
│ ├── ViewModels/
│ ├── Models/
│ └── Services/
├── Shared/
│ ├── Components/
│ ├── Styles/
│ └── Modifiers/
├── Resources/
└── Tests/
Folder Purposes
| Folder | Purpose |
|---|---|
App/ | App entry point, app-level configuration |
Core/ | Shared code across app (Extensions, Network, Utilities) |
Features/ | Feature modules (Authentication, Home, Profile...) |
Shared/ | Reusable UI components (Buttons, Cards, Modifiers) |
Resources/ | Assets, Localizable, Info.plist |
Tests/ | Unit tests, UI tests |
2. Naming Conventions
Folder Naming
Features/- Feature modules by functionalityCore/- App-wide shared codeShared/- Reusable UI componentsServices/- Business logic, API servicesResources/- Assets, Localizable, Info.plist
File Naming
| Type | Convention | Example |
|---|---|---|
| View | [Feature]View.swift | LoginView.swift |
| ViewModel | [Feature]ViewModel.swift | LoginViewModel.swift |
| Model | [EntityName].swift | User.swift |
| Service | [Name]Service.swift | AuthService.swift |
| Extension | [Type]+Extensions.swift | String+Extensions.swift |
| Component | [DescriptiveName].swift | PrimaryButton.swift |
| Protocol | [Name]Protocol.swift | AuthServiceProtocol.swift |
Component Naming
| Type | Location | Example |
|---|---|---|
| Button | Shared/Components/Buttons/ | PrimaryButton.swift |
| Input | Shared/Components/Inputs/ | PrimaryTextField.swift |
| Card | Shared/Components/Cards/ | ItemCard.swift |
| Modal | Shared/Components/Modals/ | ConfirmationModal.swift |
| Feedback | Shared/Components/Feedback/ | LoadingView.swift |
3. Organization Rules
MVVM Responsibilities
| Layer | Responsibility | Contains |
|---|---|---|
| View | UI only, no logic | SwiftUI views, layout, styling |
| ViewModel | State + business logic | @Published properties, methods |
| Model | Data structure only | Structs, Codable, Identifiable |
| Service | API + data persistence | Network calls, local storage |
Rules
- Each feature is a separate folder in
Features/ - Each feature has subfolders:
Views/,ViewModels/,Models/,Services/ - View contains UI only, no business logic
- ViewModel contains state and business logic
- Model is data structure only
- Service handles API and data persistence
- Components in
Shared/are reusable across features
Dependencies Direction
View → ViewModel → Service → Model
↓ ↓ ↓
UI Logic Data
- View depends on ViewModel
- ViewModel depends on Service
- Service depends on Model
- Model has no dependencies
4. Feature Example
Authentication Feature
Features/
└── Authentication/
├── Views/
│ ├── LoginView.swift
│ ├── RegisterView.swift
│ └── Components/
│ ├── AuthHeader.swift
│ └── SocialLoginButtons.swift
├── ViewModels/
│ ├── LoginViewModel.swift
│ └── RegisterViewModel.swift
├── Models/
│ ├── User.swift
│ ├── LoginRequest.swift
│ └── LoginResponse.swift
└── Services/
├── AuthService.swift
└── AuthServiceProtocol.swift
File Contents Overview
| File | Contains |
|---|---|
LoginView.swift | UI layout, bindings to ViewModel |
LoginViewModel.swift | @Published state, login(), validate() |
User.swift | User struct with Codable |
AuthService.swift | API calls for login, register |
Checklist
When creating new feature:
- Create folder in
Features/[FeatureName]/ - Create subfolders:
Views/,ViewModels/,Models/,Services/ - Follow naming conventions
- Keep View logic-free
- Keep Model data-only
When creating new screen:
- Create
[Name]View.swiftinViews/ - Create
[Name]ViewModel.swiftinViewModels/ - Create models if needed in
Models/ - Add Preview for View
When creating reusable component:
- Place in
Shared/Components/[Type]/ - Make it configurable via parameters
- Add Preview
- Document usage
スコア
総合スコア
50/100
リポジトリの品質指標に基づく評価
✓SKILL.md
SKILL.mdファイルが含まれている
+20
○LICENSE
ライセンスが設定されている
0/10
○説明文
100文字以上の説明がある
0/10
○人気
GitHub Stars 100以上
0/15
○最近の活動
3ヶ月以内に更新がある
0/10
○フォーク
10回以上フォークされている
0/5
✓Issue管理
オープンIssueが50未満
+5
✓言語
プログラミング言語が設定されている
+5
○タグ
1つ以上のタグが設定されている
0/5
レビュー
💬
レビュー機能は近日公開予定です