Help us measure site usage?

With your permission, we use self-hosted analytics to understand page usage. It is optional and does not affect the Service. Learn more.

SwiftintermediatemobileAI generated

Weather Forecast App

Build an iPhone weather app that uses your location to show the current conditions and a 5-day forecast, with a chart of the temperatures made with Swift Charts. It asks for location permission properly and handles every answer (including no), loads data from the free Open-Meteo API with async/await, and remembers the last forecast, so the app shows something useful when you're offline, clearly marked as not current. Pull down to refresh. You'll learn Core Location and permissions, async networking and Codable, SwiftUI state and layout, Swift Charts, caching data on the device, and designing for loading and error states.

Estimate
~12h
Steps
7
Completed by
0
Proposed by
codeseed.app

SwiftUI · CoreLocation · Swift Charts

Project roadmap

  1. 01

    Get the user's location

    ~2h

    Create a SwiftUI app and add the location usage description to Info.plist. Write a LocationManager wrapping CLLocationManager that asks for when-in-use permission and returns one location with async/await. Handle every authorization state: not asked yet, allowed, denied (show how to enable it in Settings, and offer searching for a city instead) and restricted. Done when: the app gets the current location in the simulator, and denying permission shows a helpful screen.

  2. 02

    Load the forecast

    ~2h

    Call the Open-Meteo forecast API with URLSession's async data(from:) for the coordinates, asking for current conditions and 5 days of daily highs, lows and weather codes. Decode the JSON with Codable into your own model types, converting dates properly. Show the place name using reverse geocoding (CLGeocoder). Done when: the app loads and prints the forecast for the current location.

  3. 03

    Show the current conditions

    ~1.5h

    Display the place, current temperature, feels-like temperature, wind and a description with an SF Symbol icon chosen from the weather code. Use the user's temperature units with MeasurementFormatter. Show a loading view while data loads. Done when: the current conditions display clearly with the right icon.

  4. 04

    Draw the forecast chart

    ~2h

    Use Swift Charts to draw the next 5 days: the daily high and low as lines (or a range with BarMark from low to high), with weekday labels, and the icon and temperatures listed below. Make it readable in light and dark mode and with larger text sizes. Done when: the chart shows the 5-day forecast correctly.

  5. 05

    Add refreshing and error states

    ~1.5h

    Add pull-to-refresh with .refreshable. Show friendly error views for no internet, a server error, and a location failure, each with a Retry button. Don't refresh again if the data is less than 10 minutes old unless the user pulls to refresh. Done when: every error shows a clear view, and refreshing works.

  6. 06

    Cache the last forecast

    ~1.5h

    Save the last successful forecast and its time as JSON in the app's caches folder. On launch, show the cached forecast immediately, then refresh. When refreshing fails, keep showing the cached data with a banner such as Offline, updated 2 hours ago. Done when: in airplane mode, the app shows the last forecast with the offline banner.

  7. 07

    Test it

    ~1.5h

    Write unit tests for decoding a saved API response, mapping weather codes to descriptions and icons, the cache (save, load and age), and the view model's states with a fake weather service that succeeds or fails. Done when: the tests pass.

Ready to build this?

Get a GitHub repo and start building. Your AI reviewer checks each step as you go.

~12h · 7 steps

Tech stack

SwiftUICoreLocationSwift Charts