Skip to main content
April 1, 2026Noble Desktop Publishing Team/10 min read

Hello World: Starting a Simple App

Build Your First iOS App with Swift

iOS Development Fundamentals

Xcode IDE

Apple's integrated development environment for creating iOS apps. Includes project management, code editing, and simulator testing tools.

Storyboards

Visual interface design tool that allows you to layout your app's screens and define navigation flow between them.

Auto Layout

Constraint-based layout system that ensures your app looks great across different device sizes and orientations.

Topics Covered in This iOS Development Tutorial:

Master the fundamentals of iOS app creation using Xcode and Storyboards, implementing Auto Layout for responsive design, and integrating interactive UI elements including buttons and labels.

Skills You'll Master

0/4

Exercise Preview

ex prev 1B

Exercise Overview

In this hands-on exercise, you'll build your first functional iOS application—a simple yet complete app that demonstrates the core principles of user interaction through Swift programming. When users tap a button, the app will dynamically display text, showcasing the fundamental connection between interface elements and code logic that powers every iOS application.

App Development Process

1

Project Setup

Create new Xcode project with proper configuration and file structure

2

Interface Design

Add UI elements like buttons and labels using the Object Library

3

Layout Constraints

Apply Auto Layout rules to ensure responsive design across devices

4

Code Integration

Connect interface elements to Swift code for interactive functionality

Getting Started

  1. Launch Xcode from your Applications folder. If Xcode isn't currently installed on your Mac, you'll need to download it from the Mac App Store or refer to the Setup section earlier in this workbook for detailed installation instructions. Note that Xcode requires macOS and significant disk space—ensure you have at least 15GB available.

  2. When Xcode opens, you'll typically see the Welcome to Xcode window. Click Create a new Xcode project in the center panel. If this welcome screen doesn't appear, navigate to File > New > Project from the menu bar.

  3. In the template selection screen, ensure you're on the iOS tab, then under the Application section, double-click App. This template provides the essential foundation for any iOS application.

  4. Configure your project with the following settings:

    • Product Name: HelloWorld
    • Team: None (leave unchanged for now)
    • Organization Identifier: Your Name (this becomes important for App Store distribution)
    • Interface: Storyboard (the visual interface builder)
    • Language: Swift (Apple's modern programming language)
    • Leave Use Core Data unchecked—Core Data is Apple's framework for data persistence, which we won't need for this introductory project.
    • Uncheck Include Tests to keep this tutorial focused on core development concepts.
  5. Click Next to proceed to the save location.
  6. Choose your save destination by navigating to Desktop > Class Files > yourname-iOS App Dev 1 Class folder. Organizing your projects in a dedicated folder structure will prove invaluable as you develop multiple applications.
  7. Ensure Create Git repository on my Mac is checked. Git provides version control, allowing you to track changes and revert to previous versions—an essential practice in professional development.
  8. Click Create to generate your new Xcode project.

    Xcode will now display your project's summary screen, containing metadata about your application. While most of these settings become crucial during App Store submission, our immediate focus is on building the app's core functionality.

First Launch Timing

When running your first iOS app in the simulator, expect a 60+ second launch time. This is normal for initial setup - subsequent launches will be much faster.

Project Configuration Essentials

Product Name

Choose a descriptive name like 'HelloWorld' that reflects your app's purpose and functionality.

Interface Selection

Select Storyboard for visual interface design, which provides drag-and-drop UI creation capabilities.

Git Repository

Enable version control to track changes and maintain development history throughout your project.

Understanding Storyboard, View Controller, and Object Library

Before diving into development, let's familiarize ourselves with Xcode's interface—understanding these tools will accelerate your development process significantly.

  1. The leftmost panel is the Project navigator project navigator icon, your command center for accessing all project files and resources.

    project navigator area

  2. The Project navigator displays the file structure Xcode automatically generated. Each file serves a specific purpose in your app's architecture, and we'll explore their functions throughout this tutorial.

  3. In the Project navigator, click on Main.storyboard. This file contains your app's visual interface and user flow.
  4. Xcode's workspace is organized into distinct functional areas. Understanding this layout will dramatically improve your development efficiency:

    Xcode overview

  5. The central Editor area is where you'll spend most of your time, viewing and modifying both visual interfaces and code.

    The Document Outline (second column from left) provides a hierarchical view of your interface elements. If this panel isn't visible, click the Show Document Outline button show hide document outline icon located at the bottom-left of the Editor area.

    show document outline

  6. The right-hand Utilities panel contains Inspectors—powerful tools for configuring properties and behaviors of your interface elements.

  7. In the Document Outline, locate and click on View Controller. You may need to expand the View Controller Scene triangle to reveal it. The View Controller acts as the brain of your screen, managing the logic and behavior of your interface.

  8. Now let's access Xcode's treasure trove of pre-built interface elements. In the top-right area of the Editor, click the Object Library icon object library icon to reveal the components available for your app:

object library

  1. Take a moment to scroll through this extensive collection of UI elements—these are the building blocks of every iOS app you've ever used.
  2. Rather than scrolling through hundreds of options, use the search field at the bottom of the Object Library. Type button to filter results and quickly locate the Button element.
  3. Drag the Button from the Object Library onto the center of the View in the Editor. As you drag, notice the blue alignment guides that automatically appear—these help you position elements precisely and maintain consistent spacing.

    drag button center hw2

    Pro Tip: Xcode occasionally requires a moment to process when first accessing Object Library elements. If the button doesn't appear immediately on your view, maintain your mouse hold and wait for Xcode to respond.

  4. Before proceeding, let's test our progress. In the toolbar near the top-center, next to HelloWorld, ensure iPhone 13 Pro (or your preferred simulator) is selected.
  5. Click the Run button run icon to launch the iOS Simulator. First-time launches typically require 60+ seconds as the simulator initializes—perfect time for a coffee break!

    Note: If the simulator content appears too large for your screen, navigate to Window > Physical Size to adjust the display scale.

  6. Once the simulator loads, locate the Button text in the center of the screen. Tap it and observe that while it responds visually (highlighting when pressed), it doesn't perform any action yet—we'll add that functionality shortly.
  7. Return to Xcode to continue development.
  8. Double-click directly on the Button text and change it to Show Greeting. Press Return to confirm the change—notice how the button automatically resizes to accommodate the new text.

    Next, we'll add a label to display our greeting message when the button is tapped.
  9. In the Object Library search field, type label to locate the Label element.
  10. Drag a Label from the Object Library and position it horizontally centered beneath the "Show Greeting" button, using the blue alignment guides for precision.
  11. In the right panel's inspector area, ensure the Attributes inspector attributes inspector icon is selected—this is where you'll configure the visual properties of your interface elements.
  12. Next to Font, click the small type icon font format to open font customization options.
  13. Change the Size value to 36 to make the text more prominent, then click Done.
  14. In the Attributes inspector, locate the Text field and change the label text to Hello World! (including the exclamation mark for enthusiasm).

23. To ensure professional text alignment, use the Attributes inspector to center the label text. Near the top, next to Alignment, click the center button align text center.

  1. Let's preview our progress in the Simulator. As a best practice, always click the Stop button stop icon before clicking Run run icon to ensure a clean build process.

  2. Excellent progress! Now we'll create the interactive behavior by making the text label initially invisible, allowing our button to reveal it dramatically. Return to Xcode to implement this feature.

  3. Select the Hello World! label, then in the Attributes inspector, scroll down to the Drawing section and check the Hidden option. This makes the label invisible until we programmatically show it.
  4. Test this change by clicking Stop stop icon then Run run icon to verify the label no longer appears.
  5. While in the Simulator, test device rotation by selecting Hardware > Rotate Left from the menu.

    Notice how the "Show Greeting" button's position becomes problematic or even disappears off-screen in landscape orientation. This highlights the importance of Auto Layout constraints—rules that define how interface elements should behave across different screen sizes and orientations.

Implementing Auto Layout Constraints

Auto Layout is one of iOS development's most crucial concepts, enabling your apps to look perfect across all device sizes and orientations.

  1. Return to Xcode to implement proper layout constraints.
  2. Select the Show Greeting button. Notice in the Document Outline that "Show Greeting" becomes highlighted and appears nested under "View".

    document outline hello world

  3. In the Document Outline, hold the Control key and drag from Show Greeting to View (its parent container). This creates a constraint relationship between the button and its containing view. When you release the mouse, select Center Horizontally in Safe Area from the popup menu.

    drag show greeting view

    Alternative Method: If you're using a right-click enabled mouse or trackpad, you can right-click and drag instead of using Control-drag—both methods create the same constraint connections.

  4. Success is indicated by Constraints appearing in the Document Outline under your interface elements.

  5. Now apply constraints to the label. Control-drag from the Hello World label to View and select Center Horizontally in Safe Area.
  6. Create a second constraint by Control-dragging from the label to View again, this time choosing Center Vertically in Safe Area.
  7. You may notice yellow warning lines around the label—these indicate a mismatch between the current visual position and the constraint definitions. Click the Update Frames button update frames icon at the bottom-right of the Editor to resolve this.

  8. Test the layout by clicking the Orientation button landscape orientation to switch to landscape view.
  9. If the interface appears too large, use Editor > Zoom to select a smaller viewing percentage.
  10. You'll notice the Show Greeting button appears in an unexpected location. This occurs because we've only defined horizontal constraints—the button lacks vertical positioning instructions.
  11. Switch back to Portrait orientation using the same Orientation button.
  12. In the Storyboard, drag the Show Greeting button to position it directly above the "Hello World!" label. The button should snap into position as you approach the optimal spacing.
  13. Create the final constraint by Control-dragging from the Hello World! label to the Show Greeting button in the Document Outline. Select Vertical Spacing from the popup menu to establish the relationship between these elements.

    Remember: If yellow warning lines appear, click the Update Frames button update frames icon to synchronize the visual layout with your constraints.

  14. Verify your constraint setup by testing rotation again with the Orientation button landscape orientation. Your interface elements should now maintain proper positioning in both orientations.

Connecting Interface to Code

Now comes the exciting part—bringing your interface to life through Swift code. This process demonstrates the fundamental principle of iOS development: connecting visual elements to programmatic logic.

  1. First, let's optimize our workspace for coding. Click the Adjust Editor Options button assistant editor icon in the top-right and select Assistant. This displays your storyboard and corresponding Swift code side-by-side.

drag show greeting view

  1. Create more workspace by hiding the right panel—click the utilities toggle button show hide utilities icon at the top-right.
  2. Clean up any legacy code that may be present in older Xcode versions. If you see a didReceiveMemoryWarning function, delete the entire block:

    override func didReceiveMemoryWarning() {
       super.didReceiveMemoryWarning()
       // Dispose of any resources that can be recreated.
    }
  3. Also remove any comment lines that reference "additional setup after loading the view."
  4. Your code should now look clean and minimal:

    import UIKit
    
    class ViewController: UIViewController {
    
       override func viewDidLoad() {
          super.viewDidLoad()
       }
    
    }

    Think of this code as the director controlling your app's scene. The ViewController manages the behavior of your interface elements (the "actors" on the "stage" that is your View). To control these elements, we must establish connections between the code and the interface.

  5. Let's create the first connection. Control-drag from the "Hello World" label directly into your code, positioning it just below the class ViewController line, as shown below:

    control drag label

  6. In the connection popup, enter helloLabel under Name, then click Connect.

  7. Xcode automatically generates the connection code:

    import UIKit
    
    class ViewController: UIViewController {
    
       @IBOutlet weak var helloLabel: UILabel!
    
       override func viewDidLoad() {
          super.viewDidLoad()
       }
    
    }
  8. Format your code for readability by adding line spaces above and below the @IBOutlet declaration.

    This @IBOutlet creates a reference named "helloLabel" that allows your code to control the label's properties and behavior. Now we need to create an action connection for the button.

  9. Control-drag the Show Greeting button to the space just below your @IBOutlet line.
  10. In the popup, change Connection from "Outlet" to Action—this creates a function that executes when users tap the button.
  11. Name this action toggleGreeting and click Connect. Your code now includes the action function:

    import UIKit
    
    class ViewController: UIViewController {
    
       @IBOutlet weak var helloLabel: UILabel!
    
       @IBAction func toggleGreeting(_ sender: Any) {
       }
    
       override func viewDidLoad() {
          super.viewDidLoad()
       }
    
    }

    You've just created your first Swift function—a reusable block of code that performs a specific task when called.

  12. Position your cursor between the toggleGreeting function's curly brackets and press Return to create space for your code.

Key Takeaways

1Xcode provides a complete development environment with project navigation, visual design tools, and code editing capabilities for iOS app creation
2Storyboards enable visual interface design using drag-and-drop components from the Object Library, eliminating the need to code UI elements manually
3Auto Layout constraints ensure responsive design by defining relationships between UI elements and their parent views across different device orientations
4IBOutlet connections create references to UI elements in code, allowing you to modify properties like visibility and text content programmatically
5IBAction functions respond to user interactions like button taps, enabling interactive behavior through Swift code implementation
6The iOS Simulator allows real-time testing of app functionality and layout behavior across different device configurations and orientations
7Control-drag (or right-click drag) is the primary method for creating connections between interface elements and establishing Auto Layout constraints
8Boolean properties like isHidden use true/false values, and logical operators like NOT (!) enable state toggling for interactive elements

RELATED ARTICLES