Fixing WeatherKit JWT Authentication Errors

Photo by Jonathan Bowers on Unsplash

The Problem

While integrating WeatherKit into a SwiftUI app, I kept running into the following error:

Failed to generate jwt token for: com.apple.weatherkit.authservice
Error Domain=WeatherDaemon.WDSJWTAuthenticatorServiceListener.Errors Code=2 "(null)"
❌ Failed to fetch weather

At first glance, this feels like a bug in your networking or WeatherKit usage.
It isn’t.

If your Swift code is almost certainly correct, there are other reasons for this error to crop up.

This error is caused by a missing configuration step in Apple’s signing and entitlement pipeline and it’s one of the most common (and frustrating) WeatherKit setup issues.


Why This Error Happens

Before your app can fetch weather data, Apple requires a secure authentication handshake.

That handshake involves:

  • Generating a JWT (JSON Web Token)
  • Signing it with your app’s cryptographic credentials
  • Verifying that your App ID is explicitly allowed to use WeatherKit

If any part of this chain is missing, WeatherKit fails immediately, which is exactly what this error is telling you.

In short:

❌ This is not a runtime bug
❌ This is not a simulator issue
✅ This is a capability + App Services configuration problem


The Complete Fix: WeatherKit Configuration Checklist

Follow all of these steps carefully. Skipping even one will keep the error alive.


Step 1: Enable WeatherKit Capability in Xcode

This is the most common failure point.

  1. Open your project in Xcode
  2. Select your app target
  3. Go to Signing & Capabilities
  4. Click + Capability
  5. Add WeatherKit

If WeatherKit is already listed, move on to the next step.

WeatherKit capability enabled in Xcode Signing & Capabilities


Step 2: Select the App Identifier in the Developer Portal

This step is easy to miss but mandatory.

  1. Log in to Apple Developer Portal
  2. Go to Certificates, Identifiers & Profiles
  3. Click Identifiers
  4. Select your App Identifier (this step matters, don’t skip it)

Once the App ID is selected, proceed to the next step.


Step 3: Enable WeatherKit Under App Services (Critical Step)

This was the final missing piece that fixed the error for me.

Even if WeatherKit is enabled as a capability via Xcode, check to ensure that it is enabled under Capabilities, it must also be enabled under App Services.

  1. With your App Identifier selected
  2. Open the App Services section
  3. Enable WeatherKit
  4. Save your changes

WeatherKit capability enabled for App ID

WeatherKit enabled under App Services

Without this step, JWT generation will always fail even though Xcode looks correctly configured.


Step 4: Refresh Provisioning Profiles

After changing capabilities or App Services, Xcode often uses stale profiles.

  1. Open Xcode → Settings
  2. Go to Accounts
  3. Select your Apple ID
  4. Select your team
  5. Click Download Manual Profiles

Step 5: Clean, Restart, and Test

Do a full reset to clear cached signing data:

  1. Clean Build Folder
    Shift + Command + K
  2. Quit Xcode
  3. Restart the Simulator
  4. Relaunch Xcode and run again

Strong recommendation:
Test on a physical iOS device for the first successful run.
Simulators occasionally fail WeatherKit authentication even when everything is configured correctly.


Why This Works

WeatherKit authentication is enforced at multiple levels:

  • Xcode capabilities
  • App ID entitlements
  • App Services permissions
  • Provisioning profiles

All four must align perfectly for JWT generation to succeed.

Once they do, WeatherKit “just works.”


Final Takeaway

If you see:

Failed to generate jwt token for com.apple.weatherkit.authservice

Remember this:

✔️ Your Swift code is probably fine
✔️ This is a configuration issue
✔️ App Services must be enabled, not just capabilities

This checklist should save you hours of confusion the next time you wire up WeatherKit.


Consider subscribing to my YouTube channel & follow me on X(Twitter). Leave a comment if you have any questions.

Share this article if you found it useful !