Member-only story
WWDC22: Get Started With WeatherKit
Apple’s new free API lets you make 500,000 API calls per month for free

A lot of the complexity of getting WeatherKit up and running is getting the right capability in place. Go to create an App ID on Apple’s Developer website.
You will need to enable WeatherKit on BOTH of the tabs called Capabilities and App Services. Your bundle identifier will need to be explicit, and you will need to wait at least 30 minutes after creating your App ID before trying to use WeatherKit.

Now create a new app project in Xcode 14 beta, making sure to add the WeatherKit capability on the Signing and Capabilities tab of your project file, as seen below.

So hopefully you’ve created your App ID with the right capabilities and app services and waited half an hour, then you’ve created an app project with the same bundle ID as your App ID, and finally you’ve added that capability to your project file.
Now we can actually get to the fun part, which is making a SwiftUI interface that displays weather data.
To keep this simple I’m making an app that only displays the temperature in Cupertino at the current time:
The latitude and longitude of Cuptertino were calculated using latlong.net and saved as a static CLLocation
object. In order to make the temperature big on the screen, a huge font size was selected with a minimum scale factor. This is how we access the ‘auto-shrink’ feature as it was known in UIKit. The line limit is used so that the units are not put onto a second line, which will happen if the string gets too long.