Beginner walkthrough (Swift 2 + Xcode)

Your first iOS application in Swift 2: project setup, Xcode navigation, features, and running the app

This post is a practical “first day in iOS development” guide. You’ll create a brand‑new iOS project, get comfortable with the Xcode IDE, add a tiny feature so the app does something visible, and run it in the Simulator (and optionally on a device).

Level Beginner Stack Swift 2 · iOS · Xcode Outcome A running “Hello iOS” app

You’ll be able to:

  • Create an iOS project (Single View) and understand the key settings.
  • Navigate Xcode’s panels: Navigator, Editor, Debug area, and Inspectors.
  • Add a simple UI and connect it to code (IBAction / IBOutlet).
  • Run and troubleshoot on Simulator/device using the debug console.

Before we start: Swift 2 and older Xcode versions are “legacy” today, but the fundamentals you learn here— projects, targets, storyboards, view controllers, outlets/actions, and running builds—map directly to modern iOS development.

If your Xcode doesn’t show “Swift 2” as an option, don’t worry—write the same app in your current Swift version. The UI flow and Xcode concepts are the same, and you can adjust syntax as needed.

1) Making a new iOS project (Swift 2)

Open Xcode and choose File → New → Project…. In the template chooser, select:

  • iOS (top category)
  • Application
  • Single View Application (best for a first app)

Project options you’ll see

Xcode will ask for a few details. These matter because they generate your bundle identifiers and initial structure.

  • Product Name: the name shown in Xcode and often the app’s display name.
  • Organization Name / Identifier: used to form the Bundle Identifier (example: com.yourname).
  • Language: choose Swift.
  • Devices: choose iPhone to keep things simple (you can add iPad later).
  • Use Core Data / Unit Tests / UI Tests: you can leave these unchecked for your first run.

Pick a sensible Bundle Identifier early (like com.yourdomain.FirstApp). It becomes part of signing and device installation later.

What Xcode creates for you

After you click “Create”, Xcode generates a starter app with the essentials:

  • AppDelegate.swift: application lifecycle entry points (launch, background, etc.).
  • ViewController.swift: your initial screen’s controller.
  • Main.storyboard: visual layout (a default View Controller scene).
  • Assets.xcassets: app icon and image assets.
  • Info.plist: configuration (bundle name, permissions, etc.).

2) Navigating through the IDE (Xcode)

Xcode can feel busy at first. The trick is to learn its “four regions” and what each is for.

The Navigator area (left)

This is where you browse your project: files, folders, issues, search, and source control. Most of the time you’ll live in the Project Navigator (file list).

The Editor area (center)

The Editor shows code or Interface Builder (storyboards). You can split the editor to see files side-by-side, or use the Assistant Editor to view a storyboard and its corresponding controller.

The Utility area / Inspectors (right)

Inspectors change depending on what you’ve selected. In a storyboard, you’ll frequently use:

  • Attributes Inspector: properties like text, color, font, alignment.
  • Size Inspector: constraints and layout configuration.
  • Identity Inspector: class, module, accessibility identifiers.
  • Connections Inspector: outlets and actions wiring.

The Debug area (bottom)

When you run the app, the Debug area shows logs and variables. The console is your best friend when something doesn’t behave.

Swift 2 — quick debug print
// Swift 2 commonly used `print(...)` for logs:
print("View loaded")

// If you're following older tutorials, you may see:
println("Hello") // (older Swift) — may not compile depending on toolchain

3) Add a first feature (so the app “does something”)

The simplest “feature” is: tap a button, update a label. This teaches you the two core bridges between UI and code: IBOutlet (UI → code reference) and IBAction (UI event → code function).

Step A — Build the UI in Main.storyboard

  1. Open Main.storyboard.
  2. Drag a Label onto the view. Set its text to Ready.
  3. Drag a Button onto the view. Set its title to Tap me.
  4. (Optional) Add simple constraints so it looks okay on all screen sizes.

Step B — Connect UI to ViewController.swift

Open the Assistant Editor (so you can see storyboard and code). Then:

  • Control‑drag from the Label to your code to create an IBOutlet.
  • Control‑drag from the Button to your code to create an IBAction.
ViewController.swift — minimal first feature
import UIKit

class ViewController: UIViewController {

    @IBOutlet weak var statusLabel: UILabel!

    override func viewDidLoad() {
        super.viewDidLoad()
        statusLabel.text = "Ready."
    }

    @IBAction func didTapButton(sender: UIButton) {
        statusLabel.text = "It works! 🎉"
        print("Button tapped")
    }
}

If your app crashes on launch with “unrecognized selector” or “outlet not set”, check your connections. In the storyboard, select the View Controller and review connections in the Connections Inspector. Broken outlets are very common in first projects.

Bonus: a tiny “feature” checklist you can add next

  • Change the button title after tapping (e.g., “Tapped”).
  • Use an array of messages and rotate through them.
  • Add a second screen (push or modal) to learn navigation.

4) Running the application (Simulator & device)

Choose a run destination

At the top of Xcode you’ll see a scheme and a device selector (e.g., “iPhone 6s Simulator”). Pick a simulator that matches what you want to test.

Build and run

Click the Play button or use + R. Xcode will compile your code, launch the Simulator, and start the app.

If the app doesn’t run: quick troubleshooting

  • Read the first error in the Issue Navigator—later errors may be consequences.
  • Check your target: make sure you’re building the app target (not tests).
  • Clean and rebuild: Product → Clean, then run again.
  • Storyboard connections: missing outlets/actions can crash at runtime.
  • Console logs: use print(...) to confirm code paths.

Running on a real iPhone (optional)

Device runs require signing. In Xcode’s project settings (your app target), look for Signing:

  • Select your Team (Apple ID / developer account).
  • Ensure the Bundle Identifier is unique.
  • Connect the device via USB and select it as the run destination.

The Simulator is great for speed, but real devices reveal performance and input differences. When you can, test your first app on at least one physical iPhone.

Wrap-up: what you’ve learned

You’ve created a Swift 2 iOS project, learned the essential Xcode layout, wired a UI control to code, and successfully run your app. That’s the core loop of iOS development: build UI → connect logic → run → debug → iterate.

Next steps (good beginner progression)

  1. Add a second screen and practice passing data between view controllers.
  2. Learn Auto Layout basics (constraints) so your UI adapts to different screens.
  3. Persist a value (like a tap count) using NSUserDefaults (legacy) / modern equivalents.