If you would have told me a year ago that I would write a weather app I would have laughed in your face.
Never Saw This Coming
Last year on a scale of one to ten my interest in writing a weather app that would have been a one. Besides, aren’t there already a ton of those on the App Store? And yet here we are. Two months ago I released Please Don’t Rain and I’m excited about adding new things to my weather app. How I got here is an interesting story and it taught me that stepping outside of your interests can you make you a stronger developer.
Roots in WWDC
I was one of the lucky people that got a golden ticket to WWDC at Apple Park in 2022. Just by complete chance during lunch I ran into Kai, Malin, and Zach from the Cup of Tech podcast. I went with them to watch the State of the Union.
In part of the presentation they went into detail about how the WeatherKit API would work for developers. I was so happy for Novall and she did a great job with the presentation. I distinctly remember thinking how WeatherKit was cool, but it was something that I would never use. Maybe I could see myself adding a forecast as a small part of an app in the future, but to write a dedicated weather app? Completely unthinkable.
Speaking of the unthinkable, Kai and Malin did just that. When I heard that they were going to make their own weather app from scratch, I have to admit that I was a little puzzled. Apple had recently completely revamped the iOS weather app. How on Earth could two people write something that could compete with that? Well, they did it. Mercury Weather is amazing and I use it all the time. Actually, my Apple developer friends have repeatedly shown me that you can achieve things that I would’ve thought impossible. Kai and Malin did it. Jordi Bruin wrote an app by himself that less than a year later got him nominated for an Apple Design Award. Josh Holtz created a tech conference in the United States when so many other ones have completely disappeared. I could easily keep going. To say these people inspire me is an understatement.
What Changed?
So what changed? Why did I write a Weather app? There were two main things that inspired me.
Mercury Weather
Obviously, the first one is going to be Mercury Weather. Kai and Malin showed me that it’s absolutely possible to put your own spin on a weather app even in a crowded market.
Fair Weather Friends
The other app that inspired me was Fair Weather Friends by Tim Isenman. At the time I was beta testing it he did not have a way (on purpose) for it to know your location and you had to enter the locations of your friends yourself. This really stood out to me. I loved that idea for privacy reasons. Weather apps are the first thing that I think of when I think of apps that you have to give up your location to for them to be useful. Having a weather app that does NOT know your location was just so intriguing to me.
The “Ah ha!” Moment
Even with these two apps as inspiration, I wouldn’t say that I was looking to write a weather app. But it must have been in the back of my mind. I had done about as much as I wanted to do with Foodlapse and was trying to think of another idea for my next app. One night I couldn’t sleep and I was racking my brain trying to think of pain points in my life that I could address with an app. Then all of a sudden it hit me. I am a theme park fanatic, and when I’ve got a theme park day coming up I check the weather for that day over and over again as it gets closer. I really only cared about the weather for that day and it was annoying to have to do this. That’s where the idea for Please Don’t Rain came from. Lots of apps will show you today’s weather and the weather for the next few days, but I didn’t remember ever seeing one that let you specify a place and day to keep monitoring. I had my idea!
I drew a rough sketch immediately and what I ended up with didn’t change that much in the final version.
An Unexpected Enemy Emerges
Before I started writing a weather app I assumed the most difficult part was going to be parsing mountains of JSON data that was returned from Apple Weather. I could not have been more wrong. Apple has made it a bloody delight to deal with getting back weather data from Apple Weather in Swift code. I could not get over how nice it was. What turned out to be my nemesis with something I didn’t even see coming. It was time zones. The damn time zones. It turns out that making an app where the user can be anywhere in the world, looking up weather anywhere else in the world on a specified day comes with a unique set of challenges. Bas Broek shared this video with me and honestly if I would’ve known what I was getting myself into I might not have even started!
I remember one night where I was looking at some weather data I got back and was just so confused. I was looking up the hourly weather for Brazil and the first entry I got back for the day did not say it was at midnight. Talking with Kai and Malin helped clear this up for me. What I was looking at was what time it was where I was when it was midnight in Brazil. I had a sinking feeling when I realized that there were so many places in my code that were wrong.
Wherever I printed a date like this it was wrong (I needed to format the date for their time zone).
print("The first entry is \(first.date)")
Wherever I used a Calendar to find the start of a day it was wrong (I needed to use a calendar for their time zone).
Calendar.current.startOfDay(for: theDate)
Wherever I used a Calendar to see if a date was in the selected day was wrong.
if Calendar.current.isDate(processedDate, inSameDayAs: candidate) {
Wherever I created a formatted date was wrong (Instead of .dateTime I needed to use a Date.FormatStyle for their time zone).
let dateString = Date().formatted(.dateTime.month(.twoDigits).day(.defaultDigits).hour(.defaultDigits(amPM: .abbreviated)).minute(.defaultDigits))
I was so used to typing things such as Calendar.current without even thinking about what that actually meant and it really came back to haunt me. In all of my comments for the fixes in my code I called this the “Brazil fix“ and I still shudder to think about it.
The Fun Never Ends With Time Zones
There’s so many other weird factors you have to take into consideration. If a person is in Chicago, but they select a place of Auckland New Zealand then there’s a good chance it’s already “tomorrow“ there. So I had to make sure they couldn’t enter “today’s” Chicago date after picking the place if it was already “tomorrow” there.
I wrote a widget that shows hourly temperatures so I need to refresh my data at the top of the hour right? No silly, it turns out that there are some places in the world that do not have hour offsets from UTC. It could be an additional 30 or 45 minutes, as an example. So I had to write completely new code for refreshing my widgets based on time zones. Again, what did I get myself into?
It took a lot of time and a lot of pain but I got everything working.
What became of all this? I feel a lot more comfortable working with dates and time zones, which is something I never even anticipated from working on a weather app. I also got a lot of practice with how Swift handles measurements (length, temperature, speed, etc).
Thank you
I have to point out that Kai and Malin were so kind with helping me with a lot of these issues. Having them as my weather app mentors has been a help beyond anything I can describe.
Also, a big thank you to Apple for letting developers use a good amount of WeatherKit API calls for free each month. It was a huge factor in me deciding to make a weather app.
What Does The Future Hold?
It’s almost time for WWDC again and I have to wonder about what Apple is going to release that’s going to change my trajectory. I certainly couldn’t have anticipated this before last year‘s WWDC, so I’m definitely not going try and make a prediction this year. All I know is that it’s going to be interesting.
Keep an open mind about what tools are out there, and what you can create. It might be something you never would have anticipated that ends up making you a stronger developer.
Contact
If this post was helpful to you I’d love to hear about it! I’m @MuseumShuffle@mastodon.social on Mastodon and @chriswu.com on Bluesky.
Also, whether you’re interested in becoming an iOS developer or you’re a veteran of the App Store, iOS Dev Happy Hour is a great place to meet and connect with other iOS Developers. Join us at our monthly event! We also have a new presence on Mastodon at @iosdevhappyhour@mastodon.iosdevhappyhour.com.