Skip to main content

Weather App Tutorial

⏱️ 45 minutes Build a weather app that shows current conditions and forecasts. You’ll learn about API integration, location services, and displaying real-time data.

What You’ll Build

A weather app that:
  • Shows current weather for your location
  • Displays temperature, conditions, and other details
  • Shows a multi-day forecast
  • Lets you search for other cities

Before You Start

This tutorial uses a weather API to get real data. You have two options: Apple’s built-in weather service. No API key needed, but requires iOS 16+ and works automatically.

Option B: Use OpenWeather API

Free tier available at openweathermap.org. Requires creating an account and getting an API key. For this tutorial, we’ll use WeatherKit since it’s simpler.

Part 1: Create the App

On the Nativeline home page, enter:

Complete the Wizard

  • Who is this for? — Just me
  • Feel — Modern & polished
  • Priority — Core functionality first
  • Colors — Ocean Blues (or your choice)
  • Name — Weather
Wait for the build to complete.

Part 2: Set Up Location Permission

Your app needs permission to access location. Nativeline should have set this up, but let’s verify:
When you run the app in the Simulator:
  1. You’ll see a permission popup for location
  2. Tap “Allow While Using App”
  3. The app should fetch weather for the Simulator’s default location
To change the Simulator’s location: Features → Location → Custom Location (or choose a city)

Part 3: Improve the Current Weather Display

Let’s make the current weather look better:
Your main weather display should now be informative and visually clear.

Part 4: Add Weather Details

Add more weather information:

Part 5: Improve the Forecast

Let’s enhance the 5-day forecast:
Or for a different layout:

Let users check weather for other cities:
Test searching for cities like “New York,” “London,” or “Tokyo.”

Part 7: Add Pull to Refresh

Let users manually refresh the weather:
Pull down in the Simulator to test it.

Part 8: Add Background Based on Weather

Make it visually dynamic:

Part 9: Add Hourly Forecast (Optional)

Show hour-by-hour weather:

Part 10: Add Weather Alerts (Optional)

Display severe weather warnings:

Final Result

You now have a complete weather app with:
  • ✅ Current location weather
  • ✅ Temperature and conditions
  • ✅ 5-day forecast
  • ✅ Weather details (humidity, wind, etc.)
  • ✅ City search
  • ✅ Pull to refresh
  • ✅ Dynamic backgrounds
  • ✅ (Optional) Hourly forecast
  • ✅ (Optional) Weather alerts

What You Learned


Using OpenWeather API Instead

If you prefer OpenWeather (or WeatherKit isn’t working):
  1. Sign up at openweathermap.org
  2. Get your free API key
  3. Tell Nativeline:
Never share your API key publicly. For a real app, you’d store this securely.

Troubleshooting

  • Make sure location permission is granted
  • Check that you’re connected to the internet
  • Try the Simulator’s Features → Location menu
  • Try asking: “Show a mock weather display with sample data to test the UI”
The permission popup only shows once. To reset:
  • Simulator → Device → Erase All Content and Settings
  • Or ask: “Make sure we request location permission with a usage description”
“Use Apple’s MapKit geocoding to search for cities by name”
WeatherKit requires iOS 16+. Make sure your Simulator is running iOS 16 or later, or switch to OpenWeather API.

Challenge: Extend Your App

Try these on your own:
  1. Widgets — Create a home screen widget (advanced)
  2. Favorites — Save favorite cities
  3. Notifications — Alert when rain is expected
  4. Units toggle — Switch between °F and °C
  5. Radar map — Show weather radar for your area

Next Tutorial

Photo Gallery

Learn to use camera and photo library

Notes App

Learn cloud sync with Supabase