Project Setup

Personal Catalogue: iOS (Swift & SwiftUI)

Course 1 · Chapter 1 · The App and the Empty Project

This course builds a real app for your own iPhone: a catalogue of the books, CDs, DVDs and Blu-rays you own, so that standing in a shop you can answer "do I already have this?" in a few seconds. You may already have built it for the web with PHP, Django, Express or Firebase. This is the same app, rebuilt as a native iOS app in Swift with SwiftUI for the screens and SwiftData for the database. A sister course, Personal Catalogue: Android (Kotlin & Compose), builds exactly the same app with the same chapter order, so you can follow either one, or both side by side.

What was run, and what was not
Nothing in this chapter was run. The machine this course is written on is a Windows PC with no Mac, no Xcode and no simulator, and Xcode only runs on macOS. The steps and code come from my knowledge of Xcode and SwiftUI and from the search results listed at the end of the chapter. Xcode's wizard wording, its default deployment target and its generated files change with every release, so wherever this chapter names one, trust what your own Xcode shows over the text here, and treat the code as a starting point to compile, not as something already proven to build.

What We Are Building

The app has one job and a short list of features, taken from the shared spec that both mobile courses use:

ChapterFeature added
1The empty project, folder layout, first screen in the simulator
2–3The data model and the SwiftData store, seeded with the four item types
4–5The list screen and the detail screen, with navigation between them
6One add/edit form whose labels change with the item type
7Tags: a managed, reusable list, with suggestions as you type
8Search by title or creator, filter by tag
9Duplicate warning, dark appearance, accessibility, error states
10JSON backup and restore, tests, and what to build next

The data model is small. An item has a title, a creator (author, artist or director), a "format detail" (hardcover, album, region code and so on), an optional year and some notes. Every item has one type (Book, CD, DVD or Blu-ray) and any number of tags. The app is for one person, stores everything on the phone and works with no network. Barcode scanning, cover art and cloud sync are deliberately not in this course: they are listed in the spec as later features.

How This Differs from the Web Versions

If you built a web catalogue, most of the thinking carries over and only the machinery changes:

Web catalogue (Django, PHP, Express)This course
LanguagePython, PHP or JavaScriptSwift
ScreensHTML templates or React componentsSwiftUI View structs
DatabasePostgreSQL, MySQL, MongoDB or Firestore on a serverSwiftData, on the phone
Data entryDjango admin or an HTML formA SwiftUI Form screen
ServerNeeded (Gunicorn, Apache, Node and so on)None: the app is the whole system
Running itA browser pointed at a URLThe iOS Simulator (on a Mac), or your own iPhone
UpdatesDeploy and everyone sees themInstall a new build; data lives on that one phone

The big consequence is the last two rows. There is no server and no login, so the app is simple to run but the data lives on one device. That is why Chapter 10 builds a backup file: it is the iOS equivalent of the database dump you would take from a web version.

What You Need

A Mac with Xcode. iOS apps can only be built with Xcode, which only runs on macOS. iOS Development: Fundamentals and Xcode: The IDE Itself cover installing and using it, so this chapter does not repeat that. One search source states that SwiftData needs Xcode 15.0 or later and an iOS 17.0 or later deployment target, and that apps that must support earlier versions have to use Core Data instead. That is why this course uses SwiftData with a modern minimum version.

Creating the Project

  1. In Xcode choose File > New > Project (or Create New Project on the welcome screen).
  2. Choose the iOS tab and the App template, then Next.
  3. Set Product Name to Catalogue. Pick your Team (a free personal team is enough to run on a simulator or your own phone) and an Organization Identifier, such as com.example; Xcode combines them into the bundle identifier.
  4. Set Interface to SwiftUI and Language to Swift.
  5. If the dialog offers a Storage option, choose None for now. One of the search sources recommends picking SwiftData in the wizard, which makes Xcode add a starter Item model and some container code; we write our own model in Chapter 2, so we start without it. If your Xcode has no such option, or you chose SwiftData anyway, just delete the generated Item.swift later when Chapter 2 replaces it.
  6. Choose where to save it and click Create.
  7. Select the project in the navigator, then the Catalogue target, and look at Minimum Deployments. A forum post reports that on Xcode 16.2 the template's default was iOS 18.2, well above 17.0, so check what yours says and lower it only if you need to support older phones. Do not set it below 17.0 for this course.

What the Wizard Generated

Catalogue/ ├── Catalogue.xcodeproj <- the project file (build settings, targets) ├── Catalogue/ │ ├── CatalogueApp.swift <- the entry point (@main) │ ├── ContentView.swift <- the first screen │ └── Assets.xcassets <- app icon, colours, images ├── CatalogueTests/ <- unit tests (Chapter 10) └── CatalogueUITests/ <- UI tests

CatalogueApp.swift is where the app starts: a struct marked @main that conforms to App and returns a WindowGroup containing the first view. ContentView.swift holds that first view. The exact file list and the names of the test folders can differ in your Xcode.

A Folder Layout for the Whole Course

The wizard puts everything in one group. For a small app that is fine, but this one grows through ten chapters, so decide the layout now. The groups are by responsibility, the same split the web versions made between models, views and templates:

Catalogue/ ├── CatalogueApp.swift ├── Models/ <- ItemType, Item, Tag as SwiftData models (Chapters 2-3) ├── Data/ <- seeding and the small repository (Chapter 3) ├── Views/ │ ├── List/ <- list screen (Chapter 4) │ ├── Detail/ <- detail screen (Chapter 5) │ └── Form/ <- add/edit screen (Chapter 6) ├── Backup/ <- JSON export and import (Chapter 10) └── Assets.xcassets

In the Project navigator, right-click the Catalogue group and choose New Group for each of Models, Data, Views (with List, Detail and Form inside) and Backup. Groups are for organising the navigator, and may or may not match folders on disk, depending on how your Xcode created the project; either way the layout works. Creating them now is optional: the point is to know where each thing will go.

A First Screen of Our Own

Replace the generated "Hello, world" with a screen that says what the app is. This is a sketch of the usual shape of the two generated files; yours may include a preview macro or other lines, which you should keep.

// CatalogueApp.swift import SwiftUI @main struct CatalogueApp: App { var body: some Scene { WindowGroup { ContentView() } } } // ContentView.swift import SwiftUI struct ContentView: View { var body: some View { NavigationStack { Text("My Catalogue") .font(.largeTitle) .navigationTitle("Catalogue") } } } #Preview { ContentView() }

Three ideas in that code carry the whole course. A View is a Swift struct whose body describes some UI; SwiftUI calls body again whenever the data it shows changes. A NavigationStack is the standard container for screens that push one another (the list will push the detail screen in Chapter 5), and it supplies the title bar. A modifier such as .font(.largeTitle) is a method that wraps a view in a changed copy; you chain them, and the order matters.

Running It

  1. Choose a simulated iPhone from the device menu at the top of the Xcode window.
  2. Press Run (the play button, or Command-R). The first build and simulator start-up are slow; later ones are much faster.
  3. When the simulator shows My Catalogue, you have a working toolchain. The canvas preview (the #Preview block) shows the same screen without running the app.

To run on your own iPhone, connect it by cable, trust the computer on the phone, turn on Developer Mode in the phone's settings, and choose it in the device menu; Xcode signs the build with your personal team. If the build fails, the Issue navigator lists the errors; fix the first one before the rest, since later errors often cascade from it.

Compare with the Android course
In Personal Catalogue: Android (Kotlin & Compose) Chapter 1 does the same job: a new Android Studio project, a package layout, and a first screen. The mapping is direct: a SwiftUI View is a composable function, a NavigationStack with a title is roughly a Scaffold with a top bar, and the iOS Simulator is the Android Emulator. The two apps end up with the same screens and the same data model.

Challenges

Exercise 1

Create the project as described and run it in the simulator. Write down the Product Name, Bundle Identifier, Minimum Deployment and the options your Xcode offered for Storage. Then explain in one sentence why this course needs a deployment target of iOS 17 or later.

📄 View solution
Exercise 2

Change the screen so that it shows the app name and, underneath it, a smaller line: "Books, CDs, DVDs and Blu-rays". You will need a VStack. Run it and say which argument controls the gap between the two lines.

📄 View solution
Exercise 3

Open the web catalogue course you finished (any of the four) and list, for each of the seven rows in the comparison table in this chapter, the exact file or tool you used there. Then pick the one row where iOS makes your life easier and the one where it makes it harder, and explain each in a sentence.

📄 View solution

Chapter 1 Quick Reference

  • The app: single-user, offline catalogue of books, CDs, DVDs and Blu-rays; items have a type, a creator, a format detail, an optional year, notes and tags
  • Stack: Swift, SwiftUI, SwiftData, @Observable view models, NavigationStack
  • SwiftData needs Xcode 15+ and an iOS 17+ deployment target (one source; apps for earlier versions use Core Data)
  • New project: File > New > Project > iOS > App; Interface SwiftUI; Language Swift; Storage None for now
  • Folder layout: Models, Data, Views/List, Views/Detail, Views/Form, Backup
  • A View is a struct with a body; NavigationStack holds pushed screens; modifiers chain and order matters
  • Run: choose a simulator, press Run (Command-R); or use your own iPhone with Developer Mode on
Not Yet Verified
Checked (one web search on 2026-11-19, results mostly forums and blogs, not Apple's own documentation): that the SwiftUI, Swift, SwiftData combination is the usual wizard choice; that SwiftData needs Xcode 15.0 or later and an iOS 17.0 or later deployment target; that choosing SwiftData in the wizard adds a starter Item model; and one developer's report that the default deployment target on Xcode 16.2 was iOS 18.2.
Not checked, from general knowledge: the wizard's exact field names and whether your Xcode offers a Storage option with a None choice; the generated file list; the code in both files (including #Preview and NavigationStack and that they compile together); the group layout (a design choice, not a platform rule); the simulator and Developer Mode steps; free personal team signing; and the comparison with the Android course. Nothing was built or run. Compile it, and correct anything your Xcode does differently.
Sources for This Chapter
Search results (2026-11-19): Product Builder, SwiftUI iOS app; Mehmet Baykar, SwiftData basics; Apple Developer Forums, Choosing minimum deployment targets; Andrew Bancroft, Add SwiftData to an existing app. Only the titles and short summaries in the search results were used.
Coming next
Personal Catalogue: iOS (Swift & SwiftUI) 2 designs the data model: the ItemType, Item and Tag classes as SwiftData models, the many-to-many link between items and tags, and why the same decisions you made for the Django models apply here.