- The Weather app allows you to add your favorite city to see the weather.
- It shows you the current temperature in °C and °F (switchable) and humidy in percentage.
- It can also show you the forcasts in 5 days.
- The App is written in MVVM with SwiftUI Framework.
- The API is writting with async/await.
- The app has base dependencies,
ForecastService
,TemperatureUnit
, andSaveCitiesService
- The
ForecastService
andTemperatureUnit
are working on top ofSaveCitiesService
.- The
TemperatureUnit
stores the current temperature in the storage and allows you to getcurrent
,next
andswitch
the temperature unit. - The
SavedCitiesService
saves an array of cities inString
into the storage. - The
ForecastService
works on top of theRequestManager
, to format the argument of the requests and reponses to App's Model.
- The
- The
RequestManager
works on top of theHTTPClient
which is a wrapper of theURLSession
. It helps in adapting and decoding theData
toReponseModel
. - The
StorageService
works on top of theUserDefaults
. It helps us in compile time safety and casting the values from theUserDefaults
. So we don't have to remember string of raw key and type of the value to be casted to. - The
Credential
is aPropertyWrapper
works on top of theEnvironment
which anEnvironment
works on top ofSWIFT_FLAG
- All the things I mentioned above has protocol, so we can write the unit tests for all of them.
- The unit test is 85.2% covered. This number includes the
SwiftUI*View.swift
too. - So the real number is ~ 99% covered.
- The UITesting has 4 scenario
- Launch without any city. (Assert placeholder)
- Add 2 cities. (Assert 2 cards of cities)
- Relaunch the app without resetting. (Assert 2 cities are persisted)
- Switch temperature unit. (Assert temp unit changes, and button title changes)
- Get inside city to see 5 days forcasts.
- The attachment below is taken from the
XCUITests
script.
- Please note that this the APIKey is not stored in Keychain as these following reasons.
- The APIKey is static, not fetchable like token. So it has to be stored somewhere in the project.
- So even store it in the Keychain, we need to have it somewhere in the project to write it to the Keychain.
- Normally this key should be given by an automation script or CI and buid it as part of the
.app
- The APIKey is static, not fetchable like token. So it has to be stored somewhere in the project.
- This project has none 3rd party dependency.
- There are 3 schemes and 3 targets.
- Weather
- Weather
- WeatherTests
- WeatherTests
- WeatherTests
- WeatherUITests
- WeatherUITests
- Weather
- If you want to run UnitTests, you can run Tests on
Weather
orWeatherTests
scheme. - If you want to run UITests, you have to run
WeatherUITests
scheme.