iosswiftweatherkit

WeatherKit call returning default response


I'm trying to use WeatherKit to just get a simple weather forecast for a location.

do {
    let location = CLLocation(latitude: 37.3346, longitude: -122.0087)
    let weather = try await WeatherService().weather(for: location)
} catch {
    print(error)
}

When I run this on a physical device, I get an empty Weather object and the following in the console:

[WeatherDataService] Response did not contain requested dataset: .appLocationConfig. Returning default value: AppLocationConfig(reportAnIssue: ReportIssueLocationConfig(position: beforeFooter, minDaysSinceInteraction: 0), expireTime: 2022-11-27 04:31:20 +0000

Xcode is managing my provisioning profile, I've added the WeatherKit capability, and I have an active Apple Developer Program membership, so I don't think I should be having any problems accessing WeatherKit. What's going on, and how can I fix it?


Solution

  • Whether you consider this a fix to the issue or not, adding the including parameter to the call fixed the issue for me.

    So instead of

    let weather = try await WeatherService().weather(for: location)
    

    You can call

    let weather = try await WeatherService().weather(for: location, including: .current)
    

    It should return you the same information as the original call.