【发布时间】:2022-08-17 03:36:56
【问题描述】:
嘿开发者????????????????????????????,
运行 WWDC22 Link 时出现错误
我从here 下载了 Apple 的示例项目
而且我能够运行该项目。但是当我创建一个演示项目并添加天气获取代码时,我得到了错误。
我的代码:
func fetchWeather() async {
let service = WeatherService.shared
var location: CLLocation = CLLocation(latitude: 22.7196, longitude: 75.8577)
let weatherData = try? await service.weather(for: location, including: .current)
print(weatherData)
}
错误:
2022-06-22 17:31:48.470130+0530 WeatherAPIDemo[25490:231389] [Database] Attempting to invalidate an assertion that is no longer valid 2022-06-22 17:31:49.208346+0530 WeatherAPIDemo[25490:231387] [WeatherService] Encountered an error when fetching weather data subset; location=<+22.71960000,+75.85770000> +/- 0.00m (speed -1.00 mps / course -1.00) @ 6/22/22, 5:31:48 PM India Standard Time, error=invalidJWTResponse(Optional(<NSHTTPURLResponse: 0x60000308c420> { URL: https://weather-data.apple.com/v2/token } { Status Code: 401, Headers {
Connection = (
close
);
\"Content-Length\" = (
0
);
Date = (
\"Wed, 22 Jun 2022 12:01:49 GMT\"
);
Server = (
Apple
);
\"Strict-Transport-Security\" = (
\"max-age=31536000; includeSubdomains\"
);
\"X-Apple-Origin\" = (
\"8961098f-b238-3714-ba44-5b569c861456\"
);
\"X-Cache\" = (
\"TCP_MISS from a49-44-192-207.deploy.akamaitechnologies.com (AkamaiGHost/10.8.2-41841244) (-)\"
);
\"X-Content-Type-Options\" = (
nosniff
);
\"X-Frame-Options\" = (
SAMEORIGIN
);
\"X-REQUEST-ID\" = (
\"8c733cde-5aa3-499c-b555-05c5aab5e278\"
);
\"X-XSS-Protection\" = (
\"1; mode=block\"
);
} })) 零
-
您是否拥有 Apple Developer Program 的会员资格?因为您需要将 WeatherKit 添加到您的配置文件中。
-
状态码:401,表示未经授权。您可能需要为此获得一些授权。