Create a weather app from scratch with this SwiftUI Crash Course

Поделиться
HTML-код
  • Опубликовано: 7 июл 2024
  • Create a simple weather app from scratch with SwiftUI. 🌤
    We'll learn how to get the user's current location, get the weather from that location, and display everything in a beautiful UI!
    Access the written version of this tutorial and the source files:
    ➡ Part 1: designcode.io/quick-apps-swif...
    ➡ Part 2: designcode.io/quick-apps-swif...
    ➡ Part 3: designcode.io/quick-apps-swif...
    🔗 Links mentioned in the video:
    ➡ OpenWeather website: openweathermap.org/
    ➡ HTTP Request with async/await: designcode.io/swiftui-advance...
    ➡ Data from JSON section (for preview data): designcode.io/swiftui-advance...
    ➡ OpenWeather API endpoint for New York's current weather (replace YOURAPIKEY by your API key): api.openweathermap.org/data/2...
    ➡ Reverse geocoding the coordinates: developer.apple.com/documenta...
    👩🏻‍💻 Source code on Github:
    ➡ github.com/stephdiep/WeatherApp
    🪄 Join our channel and unlock members-only perks:
    ➡ / @designcodeteam
    👋🏻 Let's connect!
    ➡ Twitter: / diepsteph
    Part 1
    0:00 - Introduction
    1:17 - Create Xcode project
    2:51 - Get the coordinates
    13:14 - Test the application
    Part 2
    14:25 - Get the weather
    20:38 - Test the application
    21:09 - Prepare the WeatherView
    Part 3
    24:08 - WeatherView UI
    30:21 - Detailed weather information
    36:13 - Conclusion

Комментарии • 143

  • @rachidfinge8601
    @rachidfinge8601 2 года назад +3

    Thanks Stephanie! I have experience in ObjC and Flutter, so this tutorial gives me all I need to get started in SwiftUI!

  • @semilife
    @semilife 2 года назад +19

    Great tutorial. Clear, fast paced and informative. Keep ip the great work look forward to watching other videos from you.

  • @TimeForTechAarush
    @TimeForTechAarush 3 месяца назад

    This gave me a boost in my SwiftUI learning path!

  • @josuegisber8150
    @josuegisber8150 2 года назад +3

    Excellent, I’ll rewatch this again

  • @x12624
    @x12624 2 года назад +22

    It took me 6 hours to complete this demo. This tutorial was a great start for my iOS app development. Thank you so much. I learnt a lot, my next step is to learn SwiftUI elements and add more functionality on top of this, like automatically changing metric to imperial and vice versa on the user input. Changing the icons automatically when the weather is hot, humid, cold, sunny, changing the background theme (day, night) based on the timing.

    • @MB-il3bk
      @MB-il3bk Год назад +1

      I could make this explanation easier tbf

  • @ronniezad323
    @ronniezad323 2 года назад +4

    thanks for kickstarting my iOS dev career...much love❤️

  • @eliwhalen604
    @eliwhalen604 2 года назад +3

    Best channel for iOS dev, thank you!

  • @markaurelius61
    @markaurelius61 2 года назад +5

    Thanks, good pacing and the final result is very polished-looking

  • @MarkBTomlinson
    @MarkBTomlinson 2 года назад +2

    Excellent presentation and explanation, thank you!

  • @ZFighter-d7k
    @ZFighter-d7k 11 месяцев назад

    nice and detailed tutorial. thanks

  • @CHITUS
    @CHITUS 2 года назад

    Thank you so much for the tutorial :))

  • @WardA-zh3si
    @WardA-zh3si 4 месяца назад

    Fantastic tutorial.

  • @michaeIbonq
    @michaeIbonq 7 месяцев назад

    best tutorial to swift !

  • @julianm080808
    @julianm080808 Месяц назад

    Thanks Stephanie for this awesome tutorial it was definitely really useful. Keep it up. God bless you.

  • @dugrut1325
    @dugrut1325 2 года назад

    I'm exhausted! Thanks

  • @dugrut1325
    @dugrut1325 2 года назад +7

    third time around, 1st time I just copied your code, app worked. But now I'm trying to understand the coding...

  • @Lian5able
    @Lian5able 2 года назад +1

    Thanks ,great tutorial.

  • @siabedi5892
    @siabedi5892 8 месяцев назад

    You are amazing!

  • @christophebeaulieu4916
    @christophebeaulieu4916 2 года назад

    Hello from Montréal 😀 amazing tutorial

  • @karanvirbilbile6018
    @karanvirbilbile6018 Год назад

    It was very helpful thank a lots

  • @mohammederrazi
    @mohammederrazi 2 года назад

    Good work 👍

  • @ellively7887
    @ellively7887 Год назад +2

    감사합니다.

  • @guntarsreiss2319
    @guntarsreiss2319 Год назад

    You can actually use simulator to test the app AND get the location. Just select Features/Location and choose any you want. So it's not mandatory to use your iphone.

  • @rajdhakate617
    @rajdhakate617 2 года назад

    Her accent made me stick to the very end. And great tutorial. Thank you

  • @secretaryofstate1
    @secretaryofstate1 8 дней назад

    great video

  • @Giovanniafram
    @Giovanniafram 2 года назад +3

    at 12:10 swift does not permit you to write that on separate lines it will have to be a continuation or else you will get an error

  • @tilupifilms
    @tilupifilms 2 года назад +8

    Would it be possible to give us a tutorial on how to include unit tests on swiftUI please? It would be great!! 😊🙏

    • @slushpuppii
      @slushpuppii Год назад

      It should give you the option when first creating the project.

  • @nblljk5576
    @nblljk5576 Год назад

    I wanted to ask you what method is used in this course, is it MVC, MVVM or something like that...just because I am curious please 🙏

  • @_thekick3r
    @_thekick3r Год назад

    I'm having an unkown error in the do catch part in ContentView (19:57), wherein my program keeps on crashing. It says to see backtrace for more information, but it says that there is an unknown error in the do catch part.
    Does anyone know the solution to this problem I'm having?

  • @jackychen8803
    @jackychen8803 2 года назад +1

    Good stuff

  • @nateperry3839
    @nateperry3839 2 года назад

    How do you get the information from the JSON, having difficulty finding it, thank you

  • @visualarts6686
    @visualarts6686 Год назад +2

    Where do I get the response body?

  • @alexanderkhrulev6688
    @alexanderkhrulev6688 2 года назад

    Thank you for this tutorial🙃 how can i make autoreload? For example every 1 hour data reload automatically?

  • @WestCoastAce27
    @WestCoastAce27 2 года назад +1

    Great job. Obj-C dev here - Swift is much easier.

  • @vamp7762
    @vamp7762 Год назад

    hey guys! so im stuck on the location manager in the code location = locations.first?.coordinate, it isn’t reading the first location tag and is giving me an error. any suggestions?

  • @applelover777
    @applelover777 2 года назад +1

    The weather logo doesn't change in the WeatherView. For example, even though its cloudy, the logo displays systemName: "sun max".

    • @DesignCodeTeam
      @DesignCodeTeam  2 года назад +5

      Yes, that's why in the conclusion I mentioned this as a possible feature to improve the app! :)
      - Stephanie

  • @GhulamMurtazaPanhwar
    @GhulamMurtazaPanhwar Год назад

    why me getting this error Fatal error: No ObservableObject of type LocationManager found. A View.environmentObject(_:) for LocationManager may be missing as an ancestor of this view.

  • @infinitespace1982
    @infinitespace1982 Год назад

    When I try to connect my phone with mac, the build fails and I get this errror
    Signing for "weather" requires a development team. Select a development team in the Signing & Capabilities editor.

  • @collinyang688
    @collinyang688 2 года назад +8

    in 18:07, were did you get the huge chunk of code?

  • @stevencooper2393
    @stevencooper2393 Год назад

    I'm getting a fatal error thread one whenever i try to fetch the data... how do i work around that?

  • @gradientO
    @gradientO 2 года назад +3

    Awesome

  • @_txrtle3019
    @_txrtle3019 Год назад +1

    Where do you get the struct ResponseBody and the others below it in the Weather manager?

    • @ashk5259
      @ashk5259 Год назад +2

      Here you go, from the GitHub: github.com/stephdiep/WeatherApp/commit/d0210ed7d4b9775d58d48f6fb842d04b9fd7a1a1
      struct ResponseBody: Decodable {
      var coord: CoordinatesResponse
      var weather: [WeatherResponse]
      var main: MainResponse
      var name: String
      var wind: WindResponse
      struct CoordinatesResponse: Decodable {
      var lon: Double
      var lat: Double
      }
      struct WeatherResponse: Decodable {
      var id: Double
      var main: String
      var description: String
      var icon: String
      }
      struct MainResponse: Decodable {
      var temp: Double
      var feels_like: Double
      var temp_min: Double
      var temp_max: Double
      var pressure: Double
      var humidity: Double
      }
      struct WindResponse: Decodable {
      var speed: Double
      var deg: Double
      }
      }
      extension ResponseBody.MainResponse {
      var feelsLike: Double { return feels_like }
      var tempMin: Double { return temp_min }
      var tempMax: Double { return temp_max }
      }

  • @haripriyaveluchamy9449
    @haripriyaveluchamy9449 2 года назад +1

    Mam it shows like Thread 1: EXC_BAD_ACCESS(code=2, address=0x7ffee5163ff8) what is the solution ?

  • @isamalzareer7721
    @isamalzareer7721 2 года назад

    if for example I want to replace the coordinates in this code with the coordinates depending on the location how do I do it?
    let coordinates = Coordinates(latitude: 12.123456, longitude: 98.987654)

    • @DesignCodeTeam
      @DesignCodeTeam  2 года назад

      Hi, the code already gets the current location of the user. If you wish to hard-code some coordinates, you'll need to create a CLLocationCoordinate2D (see developer.apple.com/documentation/corelocation/cllocationcoordinate2d).
      - Stephanie

  • @user-jw8pg7qr9e
    @user-jw8pg7qr9e 7 месяцев назад

    where did you get icon folder?

  • @drawing_kim0523
    @drawing_kim0523 2 года назад

    Hello, Stephanie! I'm studying for iOS while watching tutorial videos. I have a question while watching the video. The weather app area is in New York, USA. Can I change it to Seoul, Korea? Or should I use it in New York like a video?

    • @DesignCodeTeam
      @DesignCodeTeam  2 года назад +1

      Hi! New York is only the location for the dummy data, but you can change it to whichever location you wish, it doesn't matter! Also, the real data you'll get once you build the app will be the current weather conditions from your physical location. ☺️
      - Stephanie

  • @_txrtle3019
    @_txrtle3019 Год назад +1

    is it possible to give us the assets? would be really helpful

  • @ADJ_Music
    @ADJ_Music 11 месяцев назад

    where can I get Jason file ?????

  • @user-zg2zf1od7j
    @user-zg2zf1od7j 9 месяцев назад

    This is my First Programming Tutorial I used to code in javascript but I hate js I am thinking of relearning my coding skill from scratch

  • @asemel-khoike6154
    @asemel-khoike6154 2 года назад

    Excuse me, I think this is a problem about weatherRow the top and bottom on this design are not on the same line how to fix it

  • @TheIsaPerezShow
    @TheIsaPerezShow Месяц назад

    I’m lost on the part about the json file

  • @brightuniverse4692
    @brightuniverse4692 2 года назад +1

    I'm really confused about the code you can get from the text content to copy and paste. I don't understand where it is.

    • @DesignCodeTeam
      @DesignCodeTeam  2 года назад

      Hi, it's available on designcode.io:
      Part 1: designcode.io/quick-apps-swiftui-weather-app-1
      Part 2: designcode.io/quick-apps-swiftui-weather-app-2
      Part 3: designcode.io/quick-apps-swiftui-weather-app-1

  • @markpeck60
    @markpeck60 Год назад

    How can we add a radar?

  • @apollogamblin8246
    @apollogamblin8246 2 года назад +2

    I keep getting the error "Value of type 'Double' has no member 'roundDouble'" Does anyone have any ideas.

  • @tech4days162
    @tech4days162 2 года назад

    How do you find apis and libraries for other apps/ programs

    • @DesignCodeTeam
      @DesignCodeTeam  2 года назад

      Just do a simple research on Google for the service you're looking for with "API" at the end of your search terms and I'm sure you'll find an API/library for that. Otherwise, there's this list of public APIs hosted on Github: github.com/public-apis/public-apis
      Hope that helps!
      - Stephanie

  • @pedrodelmondes8203
    @pedrodelmondes8203 6 месяцев назад

    Where can i find the assets???

  • @ryanhua6570
    @ryanhua6570 Год назад

    I imported your code from github and it still doesn't work. is anything outdated?

  • @patrickmunyi
    @patrickmunyi 2 года назад

    Hi, great work on the App. I'm getting an error in the Content View when I try to load the weather data. The "if weather = weather " code in the Content View code is throwing an error and advising I use boolean

    • @michaelvarghesethomas8878
      @michaelvarghesethomas8878 2 года назад +2

      Leaving this answer here in case someone needs it in the future: This is most likely because you haven't yet used the variable weather yet. So the suggestion is that if you are not planning on using the variable, replace it with a boolean conditional instead

    • @michaelvarghesethomas8878
      @michaelvarghesethomas8878 2 года назад

      Leaving this answer here in case someone needs it in the future: This is most likely because you haven't yet used the variable weather yet. So the suggestion is that if you are not planning on using the variable, replace it with a boolean conditional instead

    • @Rory_-ty7fp
      @Rory_-ty7fp Год назад

      @@michaelvarghesethomas8878 Hi, you seem to understand quite a lot, I have copied her code word for word but on the weatherView page it can never make the preview as it says that there is a fatalerror in the ModelData? any ideas?

  • @user-vn5ps5nh6c
    @user-vn5ps5nh6c 5 месяцев назад

    How can I get images just like you?

  • @kingshukdeb
    @kingshukdeb Год назад

    Do we need to have an iPhone to test if location permission is working or not?

    • @wolski3714
      @wolski3714 Год назад

      nope, location works fine in emulator

  • @polirtohgl1228
    @polirtohgl1228 Месяц назад

    How to get assets?

  • @emmanuelmensah990
    @emmanuelmensah990 2 года назад +4

    ❤️

  • @tharindudarshana6480
    @tharindudarshana6480 2 года назад

    Thank You for the tutorial. I've created the app but I can't see the weather.name in the Weather App in my device - iPhone 11 Pro Max. Its the same case for 11 Pro Max in iOS simulator. But in iOS 13 Simulator I can see it. Any particular reason? Very good tutorial regardless. Thank You!

    • @DesignCodeTeam
      @DesignCodeTeam  2 года назад

      Hi Tharindu! The weather.name shouldn't be a problem on any device. Just make sure that when you query the data from the API, you get the name in the data you fetched.
      - Stephanie

    • @relax_music668
      @relax_music668 2 года назад

      I have the problem too. Always show progressview .I debuged fetched api data,but not show weatherview.

  • @Sasan_Soroush
    @Sasan_Soroush Месяц назад

    You can simulate location on Simulator, so you don't need the real device.

  • @fluxiity7094
    @fluxiity7094 2 года назад

    I'm getting an error saying 'cannot find previewWeather In scope' is there a way to fix it?

    • @DesignCodeTeam
      @DesignCodeTeam  2 года назад

      Hi! You'll need to add the preview data yourself by adding the load function with dummy JSON data for the weather: ruclips.net/video/X2W9MPjrIbk/видео.html
      The Data from JSON section can be found (with the load function) at designcode.io/swiftui-advanced-handbook-data-from-json
      - Stephanie

    • @fluxiity7094
      @fluxiity7094 2 года назад

      @@DesignCodeTeam great, thank you so much!

  • @gigipataridze3885
    @gigipataridze3885 2 года назад +1

    can you link where you copied new york weather from ? Very good Video ❤️

    • @DesignCodeTeam
      @DesignCodeTeam  2 года назад +1

      Hi!
      Just replace the YOUR_API_KEY by your own:
      api.openweathermap.org/data/2.5/weather?q=New%20York&appid=YOUR_API_KEY&units=metric
      - Stephanie

  • @fpshunter
    @fpshunter 2 года назад

    whats does it mean "manager.delegate = self" - 4 min 56 sec

    • @DesignCodeTeam
      @DesignCodeTeam  2 года назад

      We need to assign a delegate to our CLLocationManager instance, so we're assigning the class we're in (LocationManager) as its delegate
      - Stephanie

  • @gabrielarubio6130
    @gabrielarubio6130 Год назад +1

    I'm having a fatal error that states "Couldn't parse weatherdata.json as ResponseBody" does anybody have any idea on how to fix this error?

    • @Rory_-ty7fp
      @Rory_-ty7fp Год назад

      Literally going through this problem now as well. Have you checked spelling, not that that solved it for me!

    • @khaleelobrien2277
      @khaleelobrien2277 Год назад

      same issue, something is wrong with the way she is parsing that weatherData.json

    • @yatharthc6475
      @yatharthc6475 Год назад

      @@khaleelobrien2277 did you get it?

    • @yatharthc6475
      @yatharthc6475 Год назад

      did you fix it?

  • @indipow82
    @indipow82 2 года назад

    When I get to testing the application it fails. Shows nothing but a black screen and gives me and error code. EXC_BAD_ACCESS. I have checked ove the code several times and cant sort the bug.

    • @DesignCodeTeam
      @DesignCodeTeam  2 года назад

      Hi! Try to Clean Build Folder (Shift + Command + K) and build your application again. Also, you won't be able to get the weather on the Simulator, so make sure to test on an actual device.
      - Stephanie

    • @codejunkie6300
      @codejunkie6300 2 года назад

      @@DesignCodeTeam I get the same error, even when testing on an actual device. I'm using Xcode 13.2.1 and iOS 15.2. It's occuring on "@main" in the main app swift file (which points to ContentView()).

  • @nafeezahmed9468
    @nafeezahmed9468 2 года назад

    I tried to run the app on simulator it crashed! Can't we just run it on simulator? it showed me some error in fatalError like Thread1: FatalError

    • @DesignCodeTeam
      @DesignCodeTeam  2 года назад

      Hi! You're supposed to be able to run it in the Simulator, and see the WelcomeView. However, you can't get the location on the Simulator (it's not a feature supported by the Simulator) and you'll need to test it on an actual device.
      - Stephanie

    • @Martin-ml3ly
      @Martin-ml3ly 2 года назад

      @@DesignCodeTeam Actually you should be able to use the location inside the Simulator as well. Check Features > Location in the Simulator menu, there you can select predefined locations or even use a custom one.

  • @pierre-louislrt1787
    @pierre-louislrt1787 2 года назад

    When I archive the project I've Cannot find 'PreviewWeather' in scope

    • @DesignCodeTeam
      @DesignCodeTeam  2 года назад +1

      Oh, sorry about that! ModelData.swift should've been moved outside of the Preview Content folder. Then the Archive will succeed 🙂
      -Stephanie

    • @pierre-louislrt1787
      @pierre-louislrt1787 2 года назад

      @@DesignCodeTeam Greate thanks, And how can I add the forecast weather and some animation ? thanks

    • @DesignCodeTeam
      @DesignCodeTeam  2 года назад +1

      Just head over to openweathermap.org/api to learn which endpoint to call to get forecast weather. You can get the 4 days, 16 days or even 30 days forecast with the OpenWeather API. As for the animation, I suggest you to follow Meng's tutorials where he teaches how to make animations with SwiftUI!
      - Stephanie

  • @jleuthardt
    @jleuthardt 2 года назад +1

    I can't get the decode chunk at 18:05 because its locked behind a paywall. either I'm missing something or that's just shitty

    • @DesignCodeTeam
      @DesignCodeTeam  2 года назад

      Hi,
      You can get it in the source code: github.com/stephdiep/WeatherApp
      - Stephanie

  • @tarunchauhan97
    @tarunchauhan97 22 дня назад

    best part was you hide your location coordinates .... hahaha

  • @Pablo-yu7wo
    @Pablo-yu7wo 2 года назад +1

    If i use windows, can i do ios apps with swiftUI?

    • @DesignCodeTeam
      @DesignCodeTeam  2 года назад

      Hi! In the tutorial we're using Xcode, and it's only available on Mac, unfortunately 😕
      - Stephanie

    • @coffeecelestia6443
      @coffeecelestia6443 2 года назад

      You can try cloud services, but it's expensive, some like 100$/month for remote screen access to device, and it's has problems with testing on your iOS device

  • @AngelMartinez-ok7bg
    @AngelMartinez-ok7bg 2 года назад

    For some reason the weather is displayed in kelvins

  • @agent47in51
    @agent47in51 2 года назад +1

    how can get full source code ?

    • @DesignCodeTeam
      @DesignCodeTeam  2 года назад +1

      Hi, you can access it here: github.com/stephdiep/WeatherApp

  • @progra7502
    @progra7502 5 месяцев назад

    👍

  • @poonamsoni6859
    @poonamsoni6859 2 года назад

    Tell us about your secret resources

    • @DesignCodeTeam
      @DesignCodeTeam  2 года назад +1

      Hi! I would say the tutorials about SwiftUI on Design+Code, as it's a big library covering many different concepts related to SwiftUI, as well as Hacking with Swift. Those are the resources I go back to the most!
      - Stephanie

  • @Shreddderrr
    @Shreddderrr 2 месяца назад

    i get fatal error "error fetching weather data" any idea why?

    • @Owen02_
      @Owen02_ 2 месяца назад

      I’m also getting this error, were you able to fix it?

    • @Shreddderrr
      @Shreddderrr 2 месяца назад

      @@Owen02_ yes, you need to remove the double quotes when adding the api key in the link and check for any extra spaces added

    • @Shreddderrr
      @Shreddderrr 2 месяца назад

      @@Owen02_ If you get any error. copy paste the code and add "keep the code 100% as it is and fix the errors only" in chatgpt. it will keep the code styling as it is and fix the error for you. Then you can ask what was the error and how it fixed it

    • @Owen02_
      @Owen02_ 2 месяца назад

      @@ShreddderrrWhich quotes specifically? And also Is it the part of the code that’s made in the video at 16:39 ?

    • @Shreddderrr
      @Shreddderrr 2 месяца назад

      @@Owen02_can you copy paste your code

  • @ADJ_Music
    @ADJ_Music 11 месяцев назад

    can anyone help me out

  • @yanzhenhuang9820
    @yanzhenhuang9820 2 года назад

    小姐姐的母语是中文嘛?

  • @lfcblaze
    @lfcblaze Год назад

    this doesn't work - fails at too many levels.

  • @maxgs3794
    @maxgs3794 2 года назад

    I dont know how to code, i just came because she looked cute

  • @dorinai
    @dorinai 2 года назад +5

    Thank you so much for the tutorial :))