What Is iOS Development? Xcode and Your First iPhone App

iOS App Development with Swift and SwiftUI: Beginner to Job-Ready Projects · Getting Started · 7 min read · Updated

From code to screen

  1. You write Swift and SwiftUI code in a file such as ContentView.swift.
  2. Xcode checks the code and builds it into an app.
  3. Xcode installs the app on the Simulator, a pretend iPhone on your Mac.
  4. The screen shows what your code describes.

An iOS developer builds apps for the iPhone, and often for the iPad, Apple Watch and other Apple devices too. The apps you use for banking, food delivery, travel, notes and fitness are mostly built by small teams who know one language, Swift, and one toolbox, Apple's frameworks. This course teaches that path from nothing to an app you can put on a phone and show to an employer. It is 15 lessons long, and from lesson 6 onwards we build one running project, an Expense Tracker.

Before the first line of code, it helps to know the map. You will see these names in job posts, so here is what each one means.

  • Swift is the main programming language for Apple platforms. It is modern, safe and readable. This is where you start.
  • SwiftUI is Apple's newer way to build screens. You describe what the screen should look like, and the system draws it. Most new apps and tutorials use it.
  • UIKit is the older screen toolkit. Many large companies still have apps built with it, so it is worth knowing later. Lesson 15 explains how the two live together.
  • Objective-C is the language that came before Swift. You can skip it at the start. You only need it if a job involves a very old code base.
  • Xcode is the free program from Apple where you write, run, test and publish apps.

What you need

The honest answer is a Mac. Xcode only runs on macOS, and you need it to build iOS apps. There is no complete way to build and publish native iPhone apps on Windows or Linux. If you do not own a Mac, think about a second-hand or refurbished one, or a cloud Mac rental for learning, and check the price against your budget before you start. You can still read the Swift lessons (2 to 5) on any computer, because the Swift language itself runs on other systems, but the app lessons need Xcode.

  • A Mac that can run a recent version of macOS and Xcode. Apple lists which Macs and system versions each Xcode release supports, so check their page before you install.
  • Enough free disk space. Xcode and its simulators are large, often tens of gigabytes.
  • An Apple ID, which is free. A free Apple ID is enough to run your own apps on the simulator, and Apple also allows limited testing on your own device. Publishing to the App Store needs a paid Apple Developer Program membership, and the price and rules are on Apple's site, so look there for the current details.

Install Xcode

  1. Open the App Store on your Mac, search for Xcode and click Get. It is free, and the download is large, so start it early.
  2. When it finishes, open Xcode once and accept the licence. It may offer to install extra components. Let it.
  3. In Xcode, open Settings and look at the Platforms tab. Make sure an iOS simulator is installed. If not, download one there.

Create your first app

  1. In Xcode choose File > New > Project.
  2. Pick the iOS tab and then App. Click Next.
  3. Product Name: Hello. Interface: SwiftUI. Language: Swift. If Xcode asks about storage or testing, leave the defaults for now. Click Next and save the project in a folder you can find later.
  4. Xcode creates a project with a few files. Open the one called ContentView.swift.

The file contains a short piece of code. It looks a little like the one below, although the exact lines change a little between Xcode versions. You will understand every word of it by lesson 8, so for now just read it like a sentence.

import SwiftUI

struct ContentView: View {
    var body: some View {
        VStack {
            Image(systemName: "globe")
                .imageScale(.large)
            Text("Hello, world!")
        }
        .padding()
    }
}

#Preview {
    ContentView()
}

The word struct makes a new type called ContentView. The : View after it says it is a screen piece. It must have a property called body that returns what to show. Here that is a VStack, a vertical stack, holding an icon and some text. The lines that start with a dot, such as .padding(), are modifiers, and they change how a view looks. The #Preview block at the bottom shows the screen live in Xcode, on the right side, without running the app. If you do not see it, choose Editor > Canvas.

Run it in the simulator

At the top of Xcode there is a device menu with names such as iPhone 16. Choose any recent iPhone and press the Run button, the triangle, or press Command and R. Xcode builds the app, starts the Simulator and opens your app on a pretend iPhone. The first run is slow, and later runs are quicker. Press the stop button when you are done.

Now make a change. Edit the text to your own name, and add a second Text line below it. Watch the preview update. This loop of change, see, change again is the heart of SwiftUI work, and it is much faster than the old way of building screens.

struct ContentView: View {
    var body: some View {
        VStack(spacing: 12) {
            Image(systemName: "iphone")
                .font(.system(size: 48))
                .foregroundStyle(.blue)
            Text("Hello, my name is Asha")
                .font(.title)
            Text("This is my first iPhone app.")
                .foregroundStyle(.secondary)
        }
        .padding()
    }
}

What is in the project folder

  • HelloApp.swift is the starting point. It has the @main mark, which tells the system where the app begins.
  • ContentView.swift is your first screen.
  • Assets.xcassets holds images, colours and the app icon.
  • The .xcodeproj file is the project itself. Open this file, not the folder, if you come back later.
  • If you ticked testing, there are folders for tests. We use them in lesson 14.

Habits that save time

  • Read Xcode's error messages. They appear as red marks beside the line number. Click one and read the full text. The first error often causes the others.
  • Use the preview for quick layout work and the simulator for real behaviour such as navigation.
  • Use Git from day one. In lesson 15 and on this site's Git course you will learn how. Xcode can create a Git repository when you create the project.
  • Keep one small project per idea. Do not worry about making it pretty yet.

Your task

  1. Install Xcode and create an iOS App project called Hello with SwiftUI and Swift.
  2. Change the text so it shows your name and one more line of your own.
  3. Change the icon name to another one, for example star.fill or heart.fill, and change its colour.
  4. Run it in the Simulator and take a screenshot, so you can see your progress at the end of the course.

How to check it worked

  • The preview or the Simulator shows your own text and icon.
  • You can say in one sentence what Swift, SwiftUI and Xcode are.
  • You can say what a modifier is, using .padding() as an example.

Frequently asked questions

Can I learn iOS development without a Mac?

You can learn the Swift language on other systems, but building and running native iPhone apps needs Xcode, and Xcode only runs on macOS. A second-hand Mac or a cloud Mac is the usual route.

Should I learn Swift or Objective-C first?

Swift. It is the language Apple recommends for new work, and most tutorials and new apps use it. Objective-C is only needed for some older code bases.

Is SwiftUI or UIKit better for a beginner?

SwiftUI. It needs less code and updates in a live preview. UIKit is still used by many companies, so learn it after you are comfortable with SwiftUI.