WeatherApp is a native iOS application built with SwiftUI and UIKit that allows users to search for current weather information in US cities. Leveraging the OpenWeatherMap API, the app provides real-time weather data, including temperature, conditions, wind speed, and more. Additionally, it supports location-based weather retrieval and caches weather icons to enhance performance.
- Search for US Cities: Enter any US city to retrieve current weather details.
- Real-Time Weather Data: Displays temperature, weather conditions, wind speed, humidity, and visibility.
- Weather Icons: Automatically downloads and caches relevant weather icons for visual representation.
- Auto-Load Last Searched City: Remembers the last city searched and loads its weather data upon app launch.
- Location-Based Weather: Requests access to the user's location and fetches weather data based on it if permission is granted.
- Responsive Design: Supports both portrait and landscape orientations, adapting the UI for different size classes.
- Accessibility: Comprehensive accessibility support, including VoiceOver compatibility.
- Localization: Prepared for multiple languages, currently supporting English and Spanish.
- Robust Error Handling: Gracefully handles errors with user-friendly messages.
- Unit and UI Testing: Includes unit tests for ViewModel and Model layers, and UI tests for key interactions.
- SwiftUI & UIKit: For building the user interface.
- MVVM-C Architecture: Model-View-ViewModel-Coordinator pattern for clean code separation.
- Combine: For handling asynchronous events and data streams.
- CoreLocation: To access the user's location.
- MapKit: To display maps within the app.
- URLSession: For network requests to the OpenWeatherMap API.
- NSCache: To cache downloaded weather icons.
- XCTest: For unit and UI testing.
- Xcode: Ensure you have Xcode installed (version 14.0 or later recommended).
- Git: To clone the repository.
-
Clone the Repository
git clone https://github.com/tattva20/WeatherApp.git
-
Navigate to the Project Directory
cd WeatherApp
-
Open the Project in Xcode
open WeatherApp.xcodeproj
-
Configure API Key
-
Obtain an API Key:
- Sign up or log in to OpenWeatherMap to obtain your API key.
-
Add API Key to
Info.plist
:- Open
Info.plist
in Xcode. - Add a new key
OpenWeatherAPIKey
and set its value to your OpenWeatherMap API key. - Ensure that
OpenWeatherBaseURL
is set appropriately, for example:https://api.openweathermap.org/data/2.5/weather
- Open
-
Secure Your API Key:
- Make sure that
Info.plist
is included in your.gitignore
if you prefer not to expose your API key publicly. Alternatively, consider using environment variables or a secure storage method for sensitive information.
- Make sure that
-
-
Build and Run the App
-
Select Target Device:
- Choose your desired simulator or connect your physical iOS device.
-
Run the App:
- Press Run (⌘R) in Xcode to build and launch the application.
-
Grant Location Permissions:
- Upon first launch, the app will request access to your location. Granting permission will allow the app to fetch weather data based on your current location automatically.
-
-
Using the App
-
Search for a City:
- Enter the name of a US city in the search field.
- Tap on Get Weather Report to retrieve and display the current weather information.
-
View Weather Details:
- The app displays temperature, weather conditions, wind speed, humidity, and more.
- A weather icon represents the current conditions.
- A map view shows the location of the city.
-
Auto-Load Last Searched City:
- The app remembers the last city you searched for and automatically loads its weather data upon subsequent launches.
-
-
Running Tests
-
Unit Tests:
- Located in the
WeatherTests
target, covering ViewModel and Model layers.
- Located in the
-
UI Tests:
- Located in the
WeatherUITests
target, covering key user interactions.
- Located in the
-
Execute Tests:
- In Xcode, select the desired test scheme and press Command + U or navigate to Product > Test to run the tests.
-
-
Contributing
Contributions are welcome! Please follow these steps to contribute:
-
Fork the Repository
-
Create a New Branch
git checkout -b feature/YourFeatureName
-
Commit Your Changes
git commit -m "Add your message here"
-
Push to the Branch
git push origin feature/YourFeatureName
-
Create a Pull Request
Please ensure that your code adheres to the existing coding standards and passes all tests before submitting a pull request.
-
-
License
This project is licensed under the MIT License.
-
Acknowledgements
- OpenWeatherMap for providing the weather API.
- Apple's SwiftUI and Combine frameworks for enabling modern iOS development.
- Swift GitHub .gitignore for the recommended
.gitignore
settings.
-
Contact
For any inquiries or feedback, please contact Tattva20.