AI-Assisted Development for iOS

Jul 18 2025 · Swift 6.1, iOS 18, Xcode 16.3

Lesson 04: Getting Started with Claude Code

Fixing the Weather API

Episode complete

Play next episode

Next
Transcript

Now that we’ve got Claude going, let’s see if we can get it to fix this particularly gnarly and annoying bug that we have with the app, in that the API request is always returning null, and hence it looks a bit like this. And it does not tell us what yesterday’s weather looks like at all.

So I’m going to first of all jump into Claude over here. I’m going to move my face over here again. I’m going to say, although the app runs, the weather API always returns null for yesterday’s weather. Could you take a look at the API docs for Open-Meteo historical weather and see if you can fix it, please?

Okay, so it’s going to investigate. I don’t know whether this is going to work. We’ll find out. But it’s worked out that what it needs to do is research the documentation. It comes up with a nice little plan. It’s going to research the documentation, identify the error and fix it based on the documentation.

First of all it wants to go and try and access the docs for me. And once again it has asked me am I allowed to do this. I’m going to say yes. So it’s going to fetch some stuff. Right, it has completed that apparently. Found the key issue. The documentation mentions there’s a five day delay in historical weather data. This means yesterday’s weather might not be available yet.

Let me check what date we’re actually requesting and test with an older date. Okay, so it wants to do some testing, which seems like a perfectly valid thing to do. So you seven days ago instead of one day to account for Open-Meteo’s five day delay from calendar. Okay, do you want me to make this edit? All right, I mean, let’s see what it does. Let’s let it do that. So it’s going to go to seven days ago. And it wants to say a week ago. Yes, all right.

Fixed. Okay, I mean, this is true. The app is called yesterday’s weather, but that API doesn’t give us yesterday’s weather, so screw it. We’ll just ask for a week ago. Let’s find out what of that actually worked, and then we’ll try and fix it slightly better.

I’m gonna allow it. Here’s what it was like a week ago. At this time it’s clear sky 18.1 degrees C. No precipitation San Francisco. So some things to note before we overcome the fact that it’s arbitrarily changed the complete purpose of the app so that it fixes a different problem is that it’s choosing degrees C, which you would expect because the locale is set up anywhere other than the US. So we used degrees C in the rest of the world.

It thinks is in San Francisco, which is actually what it says. Features. Location. Here it is. It’s got a custom location in there. This is in San Francisco. But it’s also done the reverse geo lookup for that, which is quite good. It has selected an icon that represents clear sky. So that seems pretty reasonable to me. That’s good.

It’s requested it at 3:00, which is when it was. Which is? The time is now. It’s a little bit confusing because the location doesn’t agree with the timezone and the locale, so that’s why I need to describe it. Anyway, that is what it was like a week ago. So the API works. Claude realized what the problem was.

And in fact, if you look at the API documentation here. So this is the historical weather API documentation. It’s this bit that it found there was a five day delay. If you want information for the most recent days, you can use the forecast API and adjust the past days setting. So let’s see if we can get Claude to do that without telling it to do this and see how whether it can understand that.

Okay, this works, but the app is called yesterday’s weather. We can’t show the weather from a week ago. Do you have any other suggestions for solving this issue? Please? Okay, let’s see if it has any better ideas.

Right, yeah, absolutely right. So option one is to switch to the current weather API. Show right now weather at your location is more useful and always available. Well, the idea of the app being called yesterday’s weather, the utility of that is not really in question. It is utterly pointless, but I find it mildly entertaining.

So option two is use a different historical model. So we could use a different API. That’s good. We could use sample data. Yes. Well, we could extend it to recent weather. So fall back to the most recent data available. It really does not get my humor because it really wants to show current weather because it sounds useful. The idea of building things because they’re useful is not really in my lexicon.

So none of these what I want it to do. So I’m going to tell it what I found on the website. So this here, which is a bit disappointing because I hope that it would find this. I read the API docs and it says this. Is this an option for us?

Okay, so now it wants to go off and ask. So it’s going to go and try and find the API docs for the forecast API. So it’s understood that. Do you want to allow it? Yes, you’re allowed to go and do that. Oh, okay, interesting. So it tried to guess the URL, got it wrong. So now it’s doing a web search to try and find some answers.

What I found quite interesting about this is the way that they’ve built Claude Code as an agent is that it behaves in the same way often that I might. This is taking a little while. It really doesn’t like. I don’t know why. I’m going to exit out of here and restart it. See if that helps.

Now, it gives you a little summary. The cost. So that session cost me $0.33. Tell me how long we spent using the API. The total lines added and removed. And you can also see it mostly used Claude 3.5 Haiku, which is the smallest, fastest, cheapest model. And then when it needed a bit more, it would use Sonnet, which is the much bigger and more cleverer model, I suppose.

Take a look. This project we currently have an issue where the weather requested is from a week ago. I want yesterday. The historical API we’re using doesn’t support yesterday, but the API docs say this. Well, it was in such historical weather. Let’s copy this, paste this, say this, and see if this behaves better this time.

So let’s now go to reanalyze the codebase, which is a little frustrating, but I’ll let it do that. So it’s managed to complete the analyzing the codebase. It’s going to update the time service to be one day instead of a week ago. It’s going to switch the weather API client to use the forecast API instead of the archive, update parameters to use past days is one set of start and end date and update the UI text.

As I yesterday said a week ago, that kind of makes sense with what we were doing. It’s now going through and it wants to ask can I make this edit? So it’s do seven days ago instead of one day. So it’s getting rid of that and we’re just changing that. So yes you absolutely can.

And the other thing that I can do is that for the rest of this session, the rest of this conversation, don’t ask me every time you want to make a change, you can just do it. And I can do that with number two or by pressing shift tab. So now it’s going to just be allowed to make whatever changes it wants.

And with that, it reckons it’s finished. Okay, let’s give that a try. I’m gonna jump back over to Xcode, which is here. Gonna run it. Replace. You know, allow it to use my location. Now, it says it’s mainly clear 16.9, and that’s eight. That’s San Francisco, 8th of June 15:20. That appears to have worked.

Now, it wasn’t quite as smooth as I kind of hoped it would be, but I had to do a little bit of looking at the API, but that managed to get it to work. That was good. And if I jump back to, here’s a couple of things I want to show you.

First of all, then, please, could you commit this to the repo? So I’m going to ask it to do that. So it’s working out what the diff is. What it’ll actually do is it looks in my previous commits. It will also decide how many commits it needs to create. In this case there’s only one change. So it’s going to create the one commit.

It then tells me what command it’s actually going to run. And I’m going to say yes, I’m happy with that. And again, I can say you can do all the git stuff that you want to do. It then tells me what it’s going to show it was going to put in there. So I’m going to go with that.

And then if I then take a look at my repo, which is over here, and I open this ahead of here, we can see it’s made this. It tells you that it’s generated by Claude, generated by Claude Code, and it’s coauthored by code. But obviously it comes down to me at that point.

And it gives you fairly reasonable commit description, which means that actually, if you ask Claude to go off and do a quite a long running project, you can ask it to do sensible commits throughout the process. And it will all commit as it goes.

The final thing I want to show you before we close this video is so that I want to know there are some slash commands in here that you can use. The one I particularly want to highlight is this cost one, which whilst you’re mid-session, you can have a look and see. That’s my total cost for this session is $0.33. I’ve used four minutes of API. I’ve done four lines of code, added 11, removed exactly the same things that you’ll get when you exit the session, but you can obviously access it in the middle of working on it.

And with that, we will close this video. In the next video and final video, we are going to take a look at asking Claude to try and write some tests for part of, or maybe the whole codebase. Join me then, we’ll see how when it goes. Thank you.

See forum comments
Cinema mode Download course materials from Github
Previous: Debugging Next: Testing