Swift Package Manager Swift Version Platforms License
A lightweight, scalable and modern iOS architecture template based on Clean Architecture principles and SwiftUI.
This template provides a clean and maintainable architecture for iOS apps with clear separation of concerns, dependency injection, and SwiftUI integration.
- π Clean Architecture implementation
- π¦ Modular design
- π Async/await support
- π Simple dependency injection
- π§ͺ Testable by design
- π± SwiftUI first
- π― iOS 15+ & macOS 13+
- π§© Easy to extend
ModernCleanSwiftUI/
βββ Sources/
β βββ Domain/
β β βββ Entity.swift
β β βββ Repository.swift
β β βββ ViewState.swift
β βββ Infrastructure/
β β βββ Network/
β β βββ Storage/
β βββ Presentation/
β βββ Views/
βββ Tests/
- Add the package to your Xcode project:
dependencies: [ .package(url: "https://github.com/NSFuntik/SwiftModernArchitecture", from: "1.0.0") ]
- Import the modules you need:
import Domain import Presentation import Infrastructure
struct User: Entity { let id: UUID let name: String }
final class UsersFeature: Feature { typealias Input = UserRequest typealias Output = [User] func execute(_ input: Input) async throws -> Output { // Implementation } }
struct UsersView: View { var body: some View { LoadableView(source: usersFeature, input: .all) { users in List(users) { user in Text(user.name) } } } }
Entity: Base protocol for domain modelsRepository: Data access abstractionFeature: Combined repository and business logic
APIClient: Network communicationStorageService: Data persistence
LoadableView: Data loading containerResourceView: State handlingPaginatedView: Pagination support
-
Keep layers separate and dependencies clean:
- Domain has no dependencies
- Infrastructure depends on Domain
- Presentation depends on Domain
-
Use dependency injection:
@Inject private var feature: UsersFeature
- Handle states properly:
LoadableView(source: feature, input: input) { data in // Success state }
- Write tests for each layer:
class FeatureTests: XCTestCase { func testFeature() async throws { // Test implementation } }
- β Clear separation of concerns
- β Highly testable architecture
- β Modern Swift features
- β SwiftUI integration
- β Minimal dependencies
- β Easy to understand and extend
- β Production ready
Contributions are welcome! Please read our contributing guidelines and submit pull requests.
- iOS 15.0+
- macOS 13.0+
- Xcode 14.0+
- Swift 5.9+
This project is available under the MIT license.