BLACK FRIDAY: Save 50% on all my books and bundles! >>

SwiftUI tutorial: Building a complete project

Paul Hudson    @twostraws   

Updated for Xcode 16.4

This is a complete, free SwiftUI tutorial designed to take you through lots of its functionality in a single project. It’s aimed at people who have existing programming experience with UIKit, but most things are explained in detail so newcomers ought to be able to follow along.

Important: This was written for iOS 16.1, so you’ll need at least Xcode 14.1 to follow along. This is available as a free download from the Mac App Store if you don’t already have it.

The project we’ll be making is called iDine, and is a restaurant app that lists items in a menu and helps folks place orders. I’ve designed the project specifically so that it covers as many different techniques as possible to give you a good grounding in how things work in SwiftUI. Of course, we’re also building a real project at the same time – it’s going to be busy!

Note: If you’d like to see my completed version of this project, you can find it here on GitHub: https://github.com/twostraws/iDine.

To get started, please create a new iOS project in Xcode called “iDine”, choosing the App template. You should also select SwiftUI for the Interface, but please leave all the checkboxes unchecked.

Xcode’s project creation window, configured to create a SwiftUI app.

There are quite a few assets provided for this project that you need to copy in before you start. These are all in the assets for this project, which you can download here: https://www.hackingwithswift.com/samples/idine.zip.

Please copy them into your project like this:

  • Drag Helper.swift into your project navigator. This contains a helper extension that makes it easier to decode Codable data from a bundle. This is not related to SwiftUI, so we won’t be covering it here.
  • You should also drag Order.swift and Menu.swift into the project navigator. These are custom types that store the data we’re using in the app.
  • And drag menu.json into your project navigator too – this describes all the menu items our restaurant offers, and will be decoded into instances of MenuSection and MenuItem.
  • Drag the contents of the Images directory into your asset catalog, so we have all the pictures we need.

Dragging our artwork into Xcode’s asset catalog.

OK, that’s it – we’re ready to go!

Tip: At the end of each chapter I’ve added a “Further reading” section that suggests links to other chapters in this book. You don’t need to read them in order to follow along; they are there to provide extra information and detail if you want to understand the bigger picture more thoroughly.

Save 50% in my Black Friday sale.

SAVE 50% All our books and bundles are half price for Black Friday, so you can take your Swift knowledge further for less! Get my all-new book Everything but the Code to make more money with apps, get the Swift Power Pack to build your iOS career faster, get the Swift Platform Pack to builds apps for macOS, watchOS, and beyond, or get the Swift Plus Pack to learn Swift Testing, design patterns, and more.

Save 50% on all our books and bundles!

Similar solutions…

BUY OUR BOOKS
Buy Everything but the Code Buy Pro Swift Buy Pro SwiftUI Buy Swift Design Patterns Buy Testing Swift Buy Hacking with iOS Buy Swift Interview Challenges Buy Swift on Sundays Volume One Buy Server-Side Swift Buy Hacking with watchOS Buy Hacking with tvOS Buy Hacking with macOS Buy Dive Into SpriteKit Buy Swift in Sixty Seconds Buy Objective-C for Swift Developers Buy Beyond Code

Was this page useful? Let us know!

Average rating: 4.2/5

 
Unknown user

You are not logged in

Log in or create account