How Come My WeatherKit Sample App Doesn't Work?

I have gone through several tutorials for WeatherKit. But my sample app doesn't return weather data. The following is a list of what I have.

  1. I've registered a Bundle ID for my sample app with the WeatherKit capability on.
  2. I've created a developer profile for my sample app.
  3. I've opened my Xcode project to make sure that the WeatherKit capability is enabled.
  4. I have run my sample app with an actual device.
  5. I have waited for more than 30 minutes for the service to kick in. It's been several days.

The following is my code.

import SwiftUI
import CoreLocation
import WeatherKit

struct ContentView: View {
	@State var currentWeather: CurrentWeather?

	var body: some View {
		NavigationStack {
			List {
				Group {
					SampleCell(title: "Temperature", value: String(currentWeather?.apparentTemperature.value ?? 0.0) + "℃")
					SampleCell(title: "Cloud coverage", value: String(currentWeather?.cloudCover ?? 0.0))
					SampleCell(title: "Weather condition", value: String(currentWeather?.condition.description ?? ""))
					SampleCell(title: "Dew point", value: String(currentWeather?.dewPoint.value ?? 0.0) + "℃")
					SampleCell(title: "Humidity", value: String(currentWeather?.humidity ?? 0.0))
					SampleCell(title: "Pressure", value: String(currentWeather?.pressure.value ?? 0.0) + "mbar")
					SampleCell(title: "Pressure trend", value: String(currentWeather?.pressureTrend.description ?? ""))
					SampleCell(title: "Temperature", value: String(currentWeather?.temperature.value ?? 0.0) + "℃")
					SampleCell(title: "UV index", value: String(currentWeather?.uvIndex.value ?? 0))
					SampleCell(title: "Visibility", value: String(currentWeather?.visibility.value ?? 0.0) + "m")
				}
				SampleCell(title: "Window direction", value: String(currentWeather?.wind.direction.value ?? 0.0) + "°")
				SampleCell(title: "Window speed", value: String(currentWeather?.wind.speed.value ?? 0.0) + "km/h")
				SampleCell(title: "Gust", value: String(currentWeather?.wind.gust?.value ?? 0.0) + "km/h")
			}
			.navigationTitle(Text("CurrentWeather"))
			.task {
				let service = WeatherService()
				let location = CLLocation(
					latitude: 35.467081,
					longitude: 139.620798
				)
				do {
					let weather = try await service.weather(for: location)
					currentWeather = weather.currentWeather
				} catch let error {
					print(error.localizedDescription)
				}
			}
		}
	}
}

struct SampleCell: View {
	var title: String
	var value: String

	var body: some View {
		VStack {
			HStack {
				Text(title)
				Spacer()
				Text(value)
			}
		}
	}
}

Yet, I constantly get the following warnings.

2023-11-29 09:33:46.504737+0900 WeatherCrazyMama[15279:9734572] [WeatherDataService] Aborting silent interpolation: no interpolator object; location=CLLocationCoordinate2D(latitude: 35.467081, longitude: 139.620798) 2023-11-29 09:33:47.900605+0900 WeatherCrazyMama[15279:9734577] [AuthService] Failed to generate jwt token for: com.apple.weatherkit.authservice with error: Error Domain=WeatherDaemon.WDSJWTAuthenticatorServiceListener.Errors Code=2 "(null)" 2023-11-29 09:33:47.989603+0900 WeatherCrazyMama[15279:9734572] [WeatherService] Encountered an error when fetching weather data subset; location=<+35.46708100,+139.62079800> +/- 0.00m (speed -1.00 mps / course -1.00) @ 2023/11/29 9:33:46 AM Japan Standard Time, error=WeatherDaemon.WDSJWTAuthenticatorServiceListener.Errors 2 Error Domain=WeatherDaemon.WDSJWTAuthenticatorServiceListener.Errors Code=2 "(null)" The operation couldn’t be completed. (WeatherDaemon.WDSJWTAuthenticatorServiceListener.Errors error 2.)

What am I doing wrong? Thanks.

Answered by waynehend in 777589022

If you're still looking for a solution, try this: Sign into your developer account. Choose "Certificates, IDs and Profiles", then choose "Identifiers". Your sample app and identifier should appear on the list. Select it. On the screen that comes up you'll notice there are two tabs, Capabilities and App Services. WeatherKit must be checked ON BOTH tabs, and you must hit the SAVE button in the upper right for the checkmark to "stick".

I'm having the identical problem. Did you figure yours out?

Accepted Answer

If you're still looking for a solution, try this: Sign into your developer account. Choose "Certificates, IDs and Profiles", then choose "Identifiers". Your sample app and identifier should appear on the list. Select it. On the screen that comes up you'll notice there are two tabs, Capabilities and App Services. WeatherKit must be checked ON BOTH tabs, and you must hit the SAVE button in the upper right for the checkmark to "stick".

How Come My WeatherKit Sample App Doesn't Work?
 
 
Q