WeatherKit returns me error on main project but works on side projects.

Hi ! I'm using WeatherKit and Core Location for give to my users the weather from their long and lat.

I done this on snippet code, it works on littlest project but when I implement it on my main project I get errors

I got the developer program and activated it on Apple Developer.

2022-10-15 15:15:52.451584+0200 Sporolotor[9275:1486477] [AuthService] Failed to get remote object proxy for: com.apple.weatherkit.authservice with error: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.weatherkit.authservice was invalidated: failed at lookup with error 159 - Sandbox restriction." UserInfo={NSDebugDescription=The connection to service named com.apple.weatherkit.authservice was invalidated: failed at lookup with error 159 - Sandbox restriction.}

2022-10-15 15:15:52.452560+0200 Sporolotor[9275:1486477] [WeatherService] Encountered an error when fetching weather data subset; location=<+48.77307076,+2.34674782> +/- 0.00m (speed -1.00 mps / course -1.00) @ 15/10/2022 15:15:52 Central European Summer Time,  error=xpcConnectionFailed(Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.weatherkit.authservice was invalidated: failed at lookup with error 159 - Sandbox restriction." UserInfo={NSDebugDescription=The connection to service named com.apple.weatherkit.authservice was invalidated: failed at lookup with error 159 - Sandbox restriction.})

Sporolotor/WeatherViewModel.swift:20: Fatal error: xpcConnectionFailed(Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.weatherkit.authservice was invalidated: failed at lookup with error 159 - Sandbox restriction." UserInfo={NSDebugDescription=The connection to service named com.apple.weatherkit.authservice was invalidated: failed at lookup with error 159 - Sandbox restriction.})

2022-10-15 15:15:52.453024+0200 Sporolotor[9275:1486477] Sporolotor/WeatherViewModel.swift:20: Fatal error: xpcConnectionFailed(Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.weatherkit.authservice was invalidated: failed at lookup with error 159 - Sandbox restriction." UserInfo={NSDebugDescription=The connection to service named com.apple.weatherkit.authservice was invalidated: failed at lookup with error 159 - Sandbox restriction.})

(lldb) 

I'm getting this error also when trying to run WeatherService.weather(for: location). I've tried Xcode 14.0.1 and 14.1B3, both on iPhone with iOS 16.0.3 and in the simulator. macOS 12.6. I've enabled WeatherKit in the project and in the Capabilities and App Services tabs in the developer portal.

Hi! I had this problem myself when I started working with WeatherKit in a different project

You can resolve it by going into AppName -> Targets -> Signing & Capabilities and adding the WeatherKit capability. Hope this helps!

WeatherKit returns me error on main project but works on side projects.
 
 
Q