When I'm using the following code into the simulator it gives the wanted result:
Button {
Task {
localWeather = try await WeatherService.shared.weather(for: CLLocation(latitude: 52.5153, longitude: 6.08565), including: .daily(startDate: Date(), endDate: Calendar.current.date(byAdding: .day, value: 1, to: Date())!)).first.debugDescription
}
} label: {
Text("Get the test weather")
}
Text(localWeather)
When I'm using this exact code on a real device I get the following 404 error:
[WeatherDataService] Received invalid http response code 404 for request: C7AEC7CC-E5F7-425D-8491-25B9302E2A0F:0
[WeatherService] Encountered an error when fetching weather data subset; location=<+52.51530000,+6.08565000> +/- 0.00m (speed -1.00 mps / course -1.00) @ 05/01/2023, 13:55:53 Central European Standard Time, error=responseFailed(<NSHTTPURLResponse: 0x282ce0260> { URL: https://weather-data.apple.com/v3/weather/en/52.515/6.086?timezone=Europe/Amsterdam&dataSets=forecastHourly,forecastDaily&dailyStart=2023-01-10T12:00:00Z&dailyEnd=2023-01-10T12:00:00Z&hourlyStart=2023-01-10T11:00:00Z&hourlyEnd=2023-01-10T16:00:00Z&country=NL } { Status Code: 404, Headers {
"Access-Control-Allow-Origin" = (
"*"
);
"Cache-Control" = (
"max-age=0, no-cache, no-store"
);
Connection = (
"keep-alive"
);
"Content-Length" = (
0
);
"Content-Security-Policy" = (
"default-src 'self';"
);
Date = (
"Thu, 05 Jan 2023 12:59:27 GMT"
);
Expires = (
"Thu, 05 Jan 2023 12:59:27 GMT"
);
Pragma = (
"no-cache"
);
Server = (
"AppleHttpServer/21be5247c6351682d1d9aa22fe98c8f0d4902838"
);
"Strict-Transport-Security" = (
"max-age=31536000; includeSubDomains",
"max-age=31536000"
);
"X-Apple-Origin" = (
"bcd49c7f-c567-3921-a041-3d4ef58e5423"
);
"X-B3-TraceId" = (
c8c6547722afc53f
);
"X-Cache" = (
"TCP_MISS from a104-110-190-91.deploy.akamaitechnologies.com (AkamaiGHost/10.10.3-45298580) (-)"
);
"X-Content-Type-Options" = (
nosniff
);
"X-Frame-Options" = (
DENY
);
"X-REQUEST-ID" = (
"407e37bc-ddf6-45fd-84d0-1d3d3b8651b0"
);
"X-XSS-Protection" = (
"1; mode=block"
);
} }, Optional(""))
I fixed it once by deleting Xcode and the app from my iPhone, but that doesn't work anymore.
Any suggestions?