Start a macOS app

Create a macOS SwiftUI project

Create the correct Xcode target, name the product deliberately, and verify the app launches as a native Mac application.

12 minute lesson

~~~

You need Xcode to build Mac apps. Download it from the Mac App Store, open it, and choose File → New → Project. Pick the macOS tab, then the App template. This choice matters more than it looks: the iOS template produces a different target with different capabilities, and converting later is tedious work.

On the options screen, choose SwiftUI for the interface and Swift for the language. Name the product something you will not regret. We will build a notes app throughout this course, so Notes works well.

The organization identifier deserves a moment of attention. Xcode combines it with the product name to build the bundle identifier, something like com.flaviocopes.Notes. macOS uses this string as the identity of your app: preferences, Keychain items, and notifications are all tied to it. Use a reverse-DNS name for a domain you control, and treat it as permanent.

Before writing any code, press Cmd+R and run the untouched template. You should see a resizable window with “Hello, world!” in the middle, and the app name in the menu bar next to the Apple menu. This is your working baseline. If something breaks later, you know it was your change, not the toolchain.

Xcode generated two Swift files. The entry point looks like this:

import SwiftUI

@main
struct NotesApp: App {
  var body: some Scene {
    WindowGroup {
      ContentView()
    }
  }
}

We will unpack every line of this in the next lesson. For now, notice how small it is. There is no storyboard, no window setup code, no boilerplate delegate. SwiftUI apps on macOS start from a declaration.

Open the target settings — click the project in the navigator, then the Notes target — and look at the General tab. Record the bundle identifier, the deployment target (set it to macOS 14 for this course), and the version and build numbers. These values follow the app through its whole life, from the first debug build to the release you eventually share.

Make a git commit right now, before touching anything. When a later change breaks the build in a confusing way, a diff against the known-working template answers questions faster than guessing.

One mistake I see often: picking the Multiplatform template because it sounds more capable. It adds iOS assumptions you do not need, and the extra conditional compilation gets in the way while you learn. Choose the plain macOS App template. You can add more destinations later from the target settings if you ever want them.

Lesson completed

Take this course offline

Get every free book and course as PDF and EPUB files.

Get the download library →