Solved the issue: I forgot to include the given code in a struct and initialize the variables.
import WeatherKit
import CoreLocation
struct RequestWeather {
let weatherService = WeatherService()
let chicago = CLLocation(latitude: 47, longitude: 87.58293)
let weather : Weather
let temperature : Measurement<UnitTemperature>
init() async {
weather = try! await weatherService.weather(for: chicago)
temperature = weather.currentWeather.temperature
}
}
Post
Replies
Boosts
Views
Activity
I copied this code and ran it on my iPhone 13. The number does not change. I did confirm that my sensor was working by calling someone to see if my screen turns off.