A simple SwiftUI app that shows a 7-day weather forecast for a typed location using OpenWeather.
- Switch temperature units between °C and °F
- Search by city, address, or place name (geocoded via CoreLocation)
- Daily forecast list with icon, high/low, precipitation probability, clouds, and humidity
- Loading state and basic error handling
- SwiftUI
- MVVM (ViewModel-driven rendering)
- CoreLocation (geocoding)
- URLSession (networking)
- SDWebImageSwiftUI (remote weather icons)
- Xcode 15+ (Swift 5.9+)
- iOS 16+ target (can be adjusted in the project settings)
- OpenWeather API key
This project reads configuration values from Info.plist which are mapped from Config.xcconfig.
- Open
WeatherApp/Config.xcconfigand set your values:
//MARK: - API Keys
OPEN_WEATHER_MAP_KEY = <your_openweathermap_api_key>
//MARK: - Server URLs
BASE_URL = https://api.openweathermap.org
- Ensure
Info.plisthas the placeholders (already configured in this repo):
OPEN_WEATHER_MAP_KEY=$(OPEN_WEATHER_MAP_KEY)BASE_URL=$(BASE_URL)
The app accesses these via Config to build requests.
- Open
WeatherApp.xcodeprojin Xcode - Select an iOS Simulator or device
- Press Run
No extra steps are required; SDWebImageSwiftUI is managed by Xcode (SPM) via the project settings.
- Launch the app
- Enter a location (e.g., "Berlin", "New York", or a full address)
- Tap the search icon
- Toggle the unit picker to switch between °C and °F
- Forecast data is fetched via OpenWeather One Call API 3.0:
/data/3.0/onecall - Only daily forecasts are requested (current/minutely/hourly/alerts excluded)
- Temperature conversion is done from Kelvin to the selected unit in
ForecastViewModel
- Empty results or error: verify your API key and network connectivity
- Geocoding errors: try a more specific location string
- If icons don't load, check network access and that
SDWebImageSwiftUIis properly resolved