I have created a modular WeatherApp built using Swift, SwiftUI. I am using the MVVM architecture pattern in conjunction with Swift Packages to promote code reusability, clear separation of concerns, independent module development, easy testing, and scalability.
You will see I went an implemented modulatization by creating my own swift packages, I know that this application is simple enough to be a single application without modules but I wanted to show that I have the expertise to create and work in a modular manner.
Request Permission | Loading View | Forecast View |
---|---|---|
Location denied | No internet |
---|---|
This project follows a modular architecture pattern using Swift Packages as independent modules. The application is structured using MVVM (Model-View-ViewModel) pattern within a modular setup to promote:
- Code reusability
- Clear separation of concerns
- Independent module development
- Easy testing
- Scalability
You will see there are different views
but infact I am just replacing the view content in side the LaunchView
, these extra views are just broken into separate object to encapsulate their logig and functionality.
-
NetworkingKit
NetworkingKit is a module that abstracts networking functionality to provide simple networking services to perform networking requests. At the moment, the networking module only supports GET requests, but this can be easily modified in the future to provide other requests.
Having networking functionality encapsulated in a single module allows us to reuse networking functionality across different features without having to duplicate code. It provides a consistent networking API across different features, making it easier to maintain and update networking functionality in the future.
-
UtilityKit
UtilityKit is a module that abstracts common functionality that is likely to be shared across different features, like location services and connectivity monitoring.
Again, the benefits are similar to the other modules mentioned, most importantly it reduces duplication and increases maintainability.
CopyWeatherExample
├── Common
├── Screens
│ ├── Error
│ ├── Forecast
│ └── Launch
├── Networking
├── Package Dependencies
│ ├── NetworkingKit
│ └── LocationKit
├── Tests
I have implemented unit testing for the NetworkingKit, UtilityKit, and ForecastViewModel to ensure that the functionality works as expected, especially shared functionality exposed by the modules such as networking services.
You can run the tests on each of the modules, by opening the relevant package and running the tests or you can run the app tests from the Weather project.