Logo

dev-resources.site

for different kinds of informations.

MVVM directory structure for larger project

Published at
1/15/2025
Categories
swift
architecture
Author
pheak_pheasa
Categories
2 categories in total
swift
open
architecture
open
Author
12 person written this
pheak_pheasa
open
MVVM directory structure for larger project

Key Additions:
1. Modularization: Break the app into separate modules (e.g., UserModule, ProductModule) to improve scalability and collaboration in large teams.
2. DependencyInjection: Using DI frameworks (like Swinject) to handle dependencies across the app, improving testability and flexibility.
3. Managers: More specific app-wide managers like PushNotificationManager, AnalyticsManager for cross-functional management.
4. Tests: Better structured tests with different types of testing (e.g., unit tests, UI tests, integration tests).
5. Documentation: More extensive documentation covering architecture, APIs, and other design considerations.

MyApp/
β”‚
β”œβ”€β”€ Models/                        # Data models representing app entities
β”‚   β”œβ”€β”€ User.swift
β”‚   β”œβ”€β”€ Product.swift
β”‚   └── ...
β”‚
β”œβ”€β”€ Views/                         # UI components (Views)
β”‚   β”œβ”€β”€ MainView.swift
β”‚   β”œβ”€β”€ UserView.swift
β”‚   β”œβ”€β”€ ProductView.swift
β”‚   └── ...
β”‚
β”œβ”€β”€ ViewModels/                    # ViewModels responsible for data-binding and logic
β”‚   β”œβ”€β”€ MainViewModel.swift
β”‚   β”œβ”€β”€ UserViewModel.swift
β”‚   β”œβ”€β”€ ProductViewModel.swift
β”‚   └── ...
β”‚
β”œβ”€β”€ Services/                      # Layer for API calls, data handling, etc.
β”‚   β”œβ”€β”€ NetworkService.swift
β”‚   β”œβ”€β”€ AuthService.swift
β”‚   β”œβ”€β”€ ImageService.swift
β”‚   └── ...
β”‚
β”œβ”€β”€ Persistence/                   # Local data storage, CoreData, SQLite, etc.
β”‚   β”œβ”€β”€ CoreDataManager.swift
β”‚   β”œβ”€β”€ DatabaseMigration.swift
β”‚   └── PersistenceService.swift
β”‚
β”œβ”€β”€ Helpers/                       # Reusable utilities or helper methods
β”‚   β”œβ”€β”€ Extensions/
β”‚   β”œβ”€β”€ DateFormatterHelper.swift
β”‚   β”œβ”€β”€ NetworkingHelper.swift
β”‚   └── ...
β”‚
β”œβ”€β”€ Resources/                     # Images, JSON, etc.
β”‚   β”œβ”€β”€ Images/
β”‚   β”œβ”€β”€ Localizations/
β”‚   β”œβ”€β”€ Fonts/
β”‚   └── ...
β”‚
β”œβ”€β”€ Supporting Files/              # Configurations, AppDelegate, SceneDelegate, etc.
β”‚   β”œβ”€β”€ AppDelegate.swift
β”‚   β”œβ”€β”€ SceneDelegate.swift
β”‚   β”œβ”€β”€ Info.plist
β”‚   └── Assets.xcassets
β”‚
β”œβ”€β”€ UI/                            # UI-specific components (e.g., custom buttons, loaders)
β”‚   β”œβ”€β”€ CustomButton.swift
β”‚   β”œβ”€β”€ LoadingIndicator.swift
β”‚   β”œβ”€β”€ CustomView.swift
β”‚   └── ...
β”‚
β”œβ”€β”€ Coordinators/                  # Responsible for navigation flow
β”‚   β”œβ”€β”€ MainCoordinator.swift
β”‚   β”œβ”€β”€ UserCoordinator.swift
β”‚   └── FlowCoordinator.swift
β”‚
β”œβ”€β”€ Network/                       # Network layer, handling API calls, caching, etc.
β”‚   β”œβ”€β”€ APIClient.swift
β”‚   β”œβ”€β”€ APIConstants.swift
β”‚   β”œβ”€β”€ ResponseHandler.swift
β”‚   └── ...
β”‚
β”œβ”€β”€ Managers/                      # Handles app-wide management logic
β”‚   β”œβ”€β”€ SessionManager.swift
β”‚   β”œβ”€β”€ PushNotificationManager.swift
β”‚   └── AnalyticsManager.swift
β”‚
β”œβ”€β”€ Utils/                         # Miscellaneous utilities
β”‚   β”œβ”€β”€ AppUtils.swift
β”‚   └── Logging.swift
β”‚
β”œβ”€β”€ Modularization/                # For large projects, consider splitting into modules
β”‚   β”œβ”€β”€ UserModule/                # Example of separate feature module
β”‚   β”‚   β”œβ”€β”€ UserModels/
β”‚   β”‚   β”œβ”€β”€ UserViews/
β”‚   β”‚   β”œβ”€β”€ UserViewModels/
β”‚   β”‚   β”œβ”€β”€ UserServices/
β”‚   β”‚   └── UserCoordinator.swift
β”‚   └── ProductModule/             # Another example
β”‚       β”œβ”€β”€ ProductModels/
β”‚       β”œβ”€β”€ ProductViews/
β”‚       β”œβ”€β”€ ProductViewModels/
β”‚       β”œβ”€β”€ ProductServices/
β”‚       └── ProductCoordinator.swift
β”‚
β”œβ”€β”€ DependencyInjection/           # Dependency Injection setup (e.g., using Swinject)
β”‚   β”œβ”€β”€ DIContainer.swift
β”‚   β”œβ”€β”€ ServicesAssembly.swift
β”‚   └── ViewModelsAssembly.swift
β”‚
β”œβ”€β”€ Tests/                          # Unit and UI tests
β”‚   β”œβ”€β”€ ViewModelsTests/
β”‚   β”œβ”€β”€ ServicesTests/
β”‚   β”œβ”€β”€ PersistenceTests/
β”‚   β”œβ”€β”€ UITests/
β”‚   └── ...
β”‚
└── Documentation/                 # Project-related documentation
    β”œβ”€β”€ README.md
    β”œβ”€β”€ API_Documentation.md
    └── Architecture.md
Enter fullscreen mode Exit fullscreen mode
swift Article's
30 articles in total
Favicon
MVVM directory structure for larger project
Favicon
What Do All iOS Engineers Keep Forgetting?
Favicon
Mastering 4 way Infinite Scroll in SwiftUI!
Favicon
iOS Background Modes: A Quick Guide
Favicon
Debugging in Xcode: Tips to Save Your Time πŸ› οΈ
Favicon
I created a cool SwiftUI library!
Favicon
Optimizing iOS App Performance
Favicon
The Ultimate Guide to iOS Development: Closures (Part 7)
Favicon
Boost Your App’s Performance with Lazy Stacks in SwiftUI
Favicon
The Ultimate Guide to iOS Development: Collections (Part 6)
Favicon
Access Control Levels in Swift
Favicon
Meet swift-api-client
Favicon
The Ultimate Guide to iOS Development: Functions (Part 5)
Favicon
Unlocking Face ID Integration: Boost Security and User Experience πŸš€
Favicon
Unlocking Business Growth with iOS Development Services
Favicon
MVC vs MVVM: A Real-Life iOS Interview Insight
Favicon
The Ultimate Guide to iOS Development: Control Flow (Part 4)
Favicon
Swift: A Journey into Open Source Excellence
Favicon
Object-Oriented Programming inΒ Swift
Favicon
A Drum machine for iOS
Favicon
The Ultimate Guide to iOS Development: Variables, Data Types, and Basic Operations in Swift (Part 3)
Favicon
The Ultimate Guide to iOS Development: From Programming Basics to Building Your First App (Part 2)
Favicon
Top 5 iOS App Templates to Kickstart Your Next Project
Favicon
The Ultimate Guide to iOS Development: From Programming Basics to Building Your First App (Part 1)
Favicon
Cosmos is hiring a senior iOS eng
Favicon
How To Add Multiple Modules In The Swift Package Manager
Favicon
Enhance Debugging in Swift with #file, #line, and #function
Favicon
Directly store value using "if expression" - Swift
Favicon
Day 3: Mull It Over | Advent of Code 2024 | Swift | δΈ­ζ–‡
Favicon
Property Wrappers in Swift: From Basics to Advanced Techniques

Featured ones: