How To Create a New Xcode App Project

Written by Reinder de Vries on November 19 2020 in App Development, iOS, SwiftUI

How To Create a New Xcode App Project

You’d think that creating a new app project in Xcode is as simple as File → New → Project…, but the wizard you’ll subsequently see actually hides a lot of interesting complexity. In this tutorial, we’ll discuss the various options you have when making a new Xcode project and their effect on your app.

Here’s what we’ll get into:

  • Templates for new app projects, like the ubiquitous (Single View) App
  • Options for new projects, like code signing and SwiftUI App lifecycle
  • Learning how to set up a project by looking at example templates
  • Setting up tools like Core Data, Git and the app delegate

Ready? Let’s go.

  1. Choose Your Xcode Template
  2. App Project Options and Configuration
  3. App Project Location and Source Control
  4. Quick Tips ‘n Tricks
  5. Further Reading

Choose Your Xcode Template

We’re going to start our journey by choosing the File → New → Project… menu. The New Project wizard pops up.

Xcode new project, choose a template

With the File → New menu you can also create a new Xcode playground, a Workspace and a Swift Package. A workspace typically spans multiple projects and build targets. A Swift Package is essentially a library, with the purpose of distributing it through Swift Package Manager (SPM).

In this step of the New Project wizard, you can choose from several project templates. In essence, each project comes with its own preset configuration options and boilerplate code.

A few of them are:

  • App: Previously known as Single View App; the most common template. It’s basically an app project with the app lifecycle and one view (or view controller) already set up.
  • Game: Creates a game with Apple’s games SDKs, like SpriteKit or Metal. These templates usually include some default scene set up that you can tap into.
  • Sticker- or iMessage App. These aren’t “apps” per se, they’re more like plugins that you can add to existing apps. It’s smart to use these (if needed), because they include important presets.

You can also pick the Framework, Static Library or Metal Library templates. These aren’t complete app projects, but rather Xcode projects that produce a library or framework. You can then export that framework to another app project or distribute it online.

At the top of the template dialog, you can see a few of Apple’s platforms: iOS, macOS, watchOS, etcetera. It goes without saying that by using these tabs you can pick templates for various platforms, such as creating a Watch app or a tvOS game. They’re still Xcode projects, but their preconfigured settings give you the right starting point for your project.

Let’s move on!

Learn how to build iOS apps

Get started with iOS 14 and Swift 5

Sign up for my iOS development course, and learn how to build great iOS 14 apps with Swift 5 and Xcode 12.

App Project Options and Configuration

In the next step of the New Project wizard, you can choose options for your Xcode project. Check this out:

Xcode new project, choose options

In the above screenshot, you’re looking at the options for an iOS App project. You can set a few options:

  1. Product Name: This is the name of your app as it appears on a person’s iPhone. It’s also the name of the project itself.
  2. Team: Your App Store Connect teams show up here, if you’ve connected Xcode with your Apple ID. If you’re on the free Developer Account, choose Personal Team here.
  3. Organization/Bundle ID: This is a reverse domain name that uniquely identifies your app (in the App Store). It’s common to choose something like com.organization name.app name.
  4. Interface: Pick the UI framework you want to use to build your app. You can choose from Storyboard (UIKit) or SwiftUI.
  5. Life Cycle: This determines the approach your Xcode project uses to manage the life cycle of your app, including how your app’s initial UI is bootstrapped.
  6. Language: This needs no explanation, of course! You can choose between building an app with Objective-C or with Swift.
  7. Use Core Data: This adds some default code to your app to interact with Core Data. The same goes for Host in CloudKit and Include Tests (unit testing).

It’s worth noting here that you can change each of these options later on. You can change the name of your app, what team you use to codesign your app binary, etcetera. Some of these options, such as Use Core Data, take more effort to set up – which is why the New Project wizard is so convenient.

Especially the Interface and Life Cycle options are interesting. You can combine them like this:

↓ LC / UI → SwiftUI Storyboard
SwiftUI App Full SwiftUI app (not available)
UIKit App Delegate SwiftUI + App Delegate Full UIKit app

You can create a full SwiftUI app that uses the App protocol (iOS 14+) to bootstrap the app, or create a pre-SwiftUI app that uses storyboards and UIKit (iOS 13, 12 and lower). You can also create a SwiftUI app that uses the good ol’ App and Scene Delegates.

What about Core Data? This setting is especially useful together with the Interface and Life Cycle options. When you tick Use Core Data, the New Project wizard will add code to your Xcode project that sets up a basic Core Data configuration. Depending on what you pick exactly, you’ll get a Core Data model file, a set up managed object context, and some code that loads simple Core Data objects.

This also introduces a more nuanced benefit of the New Project wizard. You can check out how Apple would set up a project with those approaches, and learn from it. How do you add Core Data to your project? Create a temporary Xcode project, see what they did, and replicate that in your own app. Neat!

Quick Note: It’s not uncommon for these templates to change between Xcode versions, and the templates aren’t without mistakes or dubious design decisions. At the time of writing, the Core Data + SwiftUI template (Xcode 12) can potentially cause a race condition.

App Project Location and Source Control

The next step asks you where you want to save your new Xcode project. It’s pretty straightforward, but there are a few hidden options, too.

Xcode new project, choose location

It’s up to you, of course, but consider saving all your app projects in the same root folder, like ~/Documents/Xcode Projects. You can also use Time Machine or iCloud to make automatic backups of your projects.

At this point you can also tick the Create Git repository on my Mac. This will enable source control with Git for this project. Git is a super powerful tool to manage revisions in your source code.

Xcode integrates with Git, so you can see source code changes and check out specific versions of your app. If you’re using Git outside Xcode, you can disable it in Preferences.

Managing your source code with Git deserves its own tutorial (or book, rather), but it’s a great idea to play around with it. If you’re working on your own app, see if you can use git add, git commit and git push to track new features, changes or bugfixes in your app. You can use GitHub, GitLab or BitBucket to create a private code repository in the cloud.

Occasionally, Xcode will prompt you to save your new project in a folder called Autosave Information. Don’t save the project here! It’s an internal Xcode folder with temporary project data. Instead, pick something like Desktop or Documents. (Why Xcode does this is, so far, beyond anyone’s comprehension…)

Quick Tips ‘n Tricks

Awesome! In this tutorial we’ve opted to create a SwiftUI app with Core Data. After saving the project, we’re looking at the following set up in Xcode:

Xcode new project

You can see that Xcode has added quite some code for us – the template – which serves as a fruitful playground to learn more about iOS development. In this specific template, for example, you can find out how to save a new object in Core Data. Neat!

A few other quick ‘n dirty approaches are helpful if you’re learning iOS development:

  • Doing a SwiftUI tutorial? Start a new project with SwiftUI for Interface, and either UIKit or SwiftUI App (recommended) for Life Cycle.
  • Doing a UIKit tutorial? Start a new project with Storyboard for Interface and UIKit for Life Cycle.
  • Doing a SpriteKit tutorial? Start a new project with the Game template, and choose the appropriate framework (i.e., SpriteKit).

SwiftUI is not yet the default UI framework for new apps, but it’s getting there. You’ll still find plenty of UIKit- or Storyboard-based tutorials online. And if you’re looking to, say, incorporate a web view in SwiftUI, it may make more sense to quickly mock up a UIKit web view project before attempting to incorporate it in your SwiftUI app with UIViewRepresentable.

Learn how to build iOS apps

Get started with iOS 14 and Swift 5

Sign up for my iOS development course, and learn how to build great iOS 14 apps with Swift 5 and Xcode 12.

Further Reading

Awesome! You’d think that something like a New Project wizard doesn’t need a tutorial, right? As it turns out, a new project hides a lot of complexity that we can dissect and deconstruct.

Here’s what we discussed:

  • Templates for new app projects, like the ubiquitous Single View App
  • Options for new projects, like code signing and SwiftUI App lifecycle
  • Learning how to set up a project by looking at example templates
  • Setting up tools like Core Data, Git and the app delegate

Want to learn more? Check out these resources:

Reinder de Vries

Hi, I'm Reinder.
I help developers play with code.

Get the Weekly

Get iOS/Swift tutorials and insights in your inbox, every Monday.
  • This field is for validation purposes and should be left unchanged.

Most Popular

Browse Topics

Swift Sandbox

Code Swift right in your browser!
Go to the Swift Sandbox

Reinder de Vries

Reinder de Vries

Reinder de Vries is a professional iOS developer. He teaches app developers how to build their own apps at LearnAppMaking.com. Since 2009 he has developed a few dozen apps for iOS, worked for global brands and lead development at several startups. When he’s not coding, he enjoys strong espresso and traveling.

×

Build great iOS apps
Learn how in my free 7-day course

  • This field is for validation purposes and should be left unchanged.

No spam, ever. Unsubscribe anytime. Privacy Policy