ios - 无法访问 WeatherKit

标签 ios swift swiftui weatherkit

每当我尝试访问 WeatherKit 时,我总是收到此消息

2022-11-03 21:02:37.690374-0500 Weather[151:578] [AuthService] Failed to get remote object proxy for: com.apple.weatherkit.authservice with error: Error Domain=NSCocoaErrorDomain Code=407 "connection to service named com.apple.weatherkit.authservice" UserInfo={NSDebugDescription=connection to service named com.apple.weatherkit.authservice} 2022-11-03 21:02:37.6914-000 Weather[151:580] [WeatherService] Encountered an error when fetching weather data subset; location=<+37.785800,-122.441700> +/- 5.00m (speed -1.00 mps / course -1.00) @ 11/3/22, 9:02:25 PM Central Daylight Time, error=xpcConnectionFailed(Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.weatherkit.authservice" UserInfo={NSDebugDescription=connection to service named com.apple.weatherkit.authservice}) erorr 2022-11-03 21:02:37.691307-0500 Weather[15211:580478] [WeatherService] Encountered an error when fetching weather data subset; location=<+37.7800,-122.401700> +/- 5.00m (speed -1.00 mps / course -1.00) @ 11/3/22, 9:02:25 PM Central Daylight Time, error=xpcConnectionFailed(Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.weatherkit.authservice" UserInfo={NSDebugDescription=connection to service named com.apple.weatherkit.authservice}) erorr 2022-11-03 21:02:38.15636-0500 Weather[1511:5478] [AuthService] Failed to get remote object proxy for: com.apple.weatherkit.authservice with error: Error Domain=NSCocoaErrorDomain Code=409 "connection to service named com.apple.weatherkit.authservice" UserInfo={NSDebugDescription=connection to service named com.apple.weatherkit.authservice} 2022-11-03 21:02:38.1562-0500 Weather[15211:588] [WeatherService] Encountered an error when fetching weather data subset; location=<+37.783400,-122.4000> +/- 5.00m (speed -1.00 mps / course -1.00) @ 11/3/22, 9:02:38 PM Central Daylight Time, error=xpcConnectionFailed(Error Domain=NSCocoaErrorDomain Code=4097 "connection to service named com.apple.weatherkit.authservice" UserInfo={NSDebugDescription=connection to service named com.apple.weatherkit.authservice})

代码:

Task {
        do {
            let result = try await service.weather(for: location)
            print(result)
        }
        catch {
            print("error")
        }
    }

这与 Auth 有关吗?我还在我的应用程序包中启用了 WeatherKit,但仍然收到此响应。

最佳答案

确保将 WeatherKit 添加为目标的“签名和功能”中的一项功能。

关于ios - 无法访问 WeatherKit,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74311436/

相关文章:

ios - 从 iOS 中的 magento 2.0 获取完整图像 URL

iphone - 类(class)值(value)始终为-1

ios - 包括AFnetworking链接器错误

swift:返回具有相同位置的子节点

swiftui - 如何在 SwiftUI 中的形状中有文字?

ios - UIScrollView 委托(delegate)属性无法正常工作

ios - Swift - 如何将复杂对象写入 Firebase 实时数据库

ios - 使用私有(private)全局变量作为扩展名 'properties' 是否有代码味道?

ios - 使用 SwiftUI 和 contentMode = .aspectFit 动态裁剪图像

swiftui - 是否可以在 Text() 中添加内嵌按钮?