Want to add weather conditions to your app? Here's how to adopt Apple's WeatherKit API with actors and widgets, including smart refresh strategies to keep your data fresh without draining battery.

🔗: https://www.wesleymatlock.com/getting-started-with-weatherkit-in-swiftui/ by Wesley Matlock

#SwiftUI #WeatherKit #iOSDev

Getting Started with WeatherKit in SwiftUI

Professional iOS Engineer specializing in SwiftUI, VisionOS, and modern Apple platforms. Expert in HealthKit, tvOS, watchOS and even some VisionOS development with 50+ technical articles and comprehensive portfolio.

Wesley Matlock

Let's say I have a class that interacts with #WeatherKit in #swiftlang
I would like to test that class using mocks.
Now I have already added a protocol that mimics WK's WeatherService and added compliance to it: so now my WeatherService dependency can be mocked.
But the function I need returns a Weather modem and I can't figure out how to create Weather mock objects: the init is not public, except the (from: decoder) one.
What am I missing?

#unittests #iosdev

Na oficiálním fóru taky ticho po pěšině.

#Apple #WeatherKit

#Apple měl dnes výpadek u své placené služby #WeatherKit plných 16 hodin. To je až nepochopitelné. Píše se o tom někde? Budeme muset přidat do integrací tuto alternativu a počítat s 24 hodinovým výpadkem.

Had a talk with my mentors at @mercury this weekend and as usual they helped me understand. The fact that WeatherKit is returning iOS 18 monthlyStatistics() that do not match the location I asked for might be ok because it's still close to what location I'm asking for.

In my small samples it seems to be approx within 45-55m.

Since there's no mention of this in the docs I don't know how far away is too far. Right now I'm going with less than 100m.

Updated FB14326476 about this.

#WeatherKit

I've got a theory that WeatherKit was enhanced for iOS 17 users with the recent additions for iOS 18 that we're now testing.

I'm adding some new features to the iOS 17 version of Please Don't Rain and just realized that I'm seeing sleet on my precipitation chart. I have NEVER seen that before. It's only been rain and snow returned (and I have looked at a LOT of forecasts).

I felt like a proud papa watching his kid handle a new situation appropriately. 🥹

#WeatherKit #SwiftCharts

I hit an issue with the new HistoricalComparisons that can be returned with WeatherKit in iOS 18.

In this code the print statement can show the contents just fine. If you try the same thing with Logger it won't compile and gives the error: "failed to produce a diagnostic for expression".

It will compile if you use String(describing:), but the user isn’t given any indication that will fix it in the error message. I had to figure it out on my own.

Filed FB14174429

#SwiftUI #WeatherKit

I've noticed an elevated number of connection failures to WeatherKit, and I'm attempting to engage with Apple to get them fixed. Apologies if the app isn't updating, hopefully this will get resolved soon. (FB13965841) #weatherkit

Now, this is the first version of the app, I have tons of ideas to improve it but I wanted to get it in people's hands and see what people like, what they want, and how it's used 🙂

On the technical side, the app is entirely built in #SwiftUI (what did you expect?), and leverages #CoreLocation, #MapKit, #WeatherKit and a little bit of #SwiftCharts.

This app is the reason I filed and share many feedback related to these frameworks lately 😄

#iOS #AppStore #IndieDev

The #SwiftUI series on building a full #WeatherKit app is complete.
In this video we create functions to encode and decode our list and as JSON stored in app Documents Directory.
https://youtu.be/bW52ZSOGWek
Full Series: https://youtube.com/playlist?list=PLBn01m5Vbs4B7bGUeaWJLi9mGqxYVJaAG&si=zBkpcG6PGOYx_c05
7 WeatherKit Persisting the Cities List

YouTube