DEV Community

Cover image for The Ultimate Guide to iOS Development: From Programming Basics to Building Your First App (Part 2)
AB Dev Hub
AB Dev Hub

Posted on

The Ultimate Guide to iOS Development: From Programming Basics to Building Your First App (Part 2)

Hello, dear readers! 👋 Welcome to AB Dev Hub 2nd article in a series of iOS development course, that will still cover some theory and history, but that needed to be done.

Image description

Today, we’re diving into one of the most exciting topics for iOS and macOS developers: the Swift programming language. Together, we’ll explore its history and evolution, discuss its modern features, and even take a peek into Apple’s powerful Integrated Development Environment (IDE), Xcode.

As a bonus, we’ll introduce you to Playground, Xcode’s interactive environment for learning and experimenting with Swift. Finally, we’ll wrap up by writing and running our very first Swift program—an excellent starting point for anyone eager to jump into Apple app development.

So, grab your favorite beverage, fire up your Mac, and let’s get started! 🚀

Overview of the Apple Ecosystem and Swift: A Tale of Innovation

When you think of Apple, you might picture sleek iPhones, iconic MacBooks, or the transformative Apple Watch. But behind this ecosystem of devices lies a powerful programming language that empowers developers to create seamless and dynamic apps for millions of users worldwide. I am speaking about Swift, Apple's modern, versatile, and developer-friendly programming language.

What is Swift?

Image description

Swift is a general-purpose programming language designed by Apple in 2014. It is fast, safe, and intuitive, allowing developers to create everything from simple apps to complex systems for iOS, macOS, watchOS, and tvOS. Swift was designed to be easy to learn and use while maintaining the power needed for professional software development.

Its core philosophy revolves around three key principles:

  1. Speed and Performance: Swift leverages modern compiler technology to optimize app performance. It’s built to handle everything from real-time animations to data-intensive tasks.
  2. Safety First: Common programming pitfalls, like null pointer exceptions, are minimized with Swift’s strict type system and features like optional binding.
  3. Expressiveness: The syntax is clean and concise, making code easier to write, read, and maintain.

Swift has quickly become a favorite among developers due to its combination of modern features and backward compatibility with Objective-C, Apple’s previous dominant programming language.

The History and Evolution of Swift

The Beginning: A Language Built for the Future

The story of Swift begins in 2010 when Chris Lattner, an Apple engineer, envisioned a programming language that would simplify coding for developers. By 2014, Swift was officially introduced at Apple’s Worldwide Developers Conference (WWDC), touted as a language “Objective-C without the C.”

Key highlights of its initial release:

  • Playgrounds: A real-time interactive coding environment that lets developers experiment with code (but you know what - it is still a super laggy baggy app, but still it’s convenient for start, so we will use that a lot studying swift)
  • Simplified Syntax: Reduced boilerplate code, allowing faster app development.
  • Compatibility with Objective-C: Developers could seamlessly integrate Swift code into existing Objective-C projects.

Rapid Growth: Gaining Traction

Swift’s open-sourcing in 2015 was a pivotal moment. By releasing Swift’s source code to the public, Apple invited the global developer community to contribute, innovate, and adopt the language.

Key milestones during this phase:

  • Swift Package Manager: Introduced to streamline dependency management.
  • Swift Playgrounds App: Launched as a fun way to teach coding to kids and beginners.
  • Cross-platform Support: Expanding beyond Apple’s ecosystem to Linux.

Evolution and Maturity

Swift didn’t stop at being a developer’s favorite—it evolved to meet the demands of large-scale applications and emerging technologies.

  • ABI Stability (Swift 5): With Application Binary Interface (ABI) stability in 2019, Swift apps became smaller and more efficient.
  • Concurrency: Introduced in Swift 5.5, the async and await features made handling asynchronous tasks more intuitive.
  • SwiftUI Framework: Launched in 2019, SwiftUI revolutionized UI development by allowing developers to design interfaces declaratively. (still not used as much as IOS Developers want, but it is absolutely ok and just need’s some time to be completed and cleared of bugs that still inside the box of SwiftUI)

Swift Today and Beyond

Swift continues to grow, adapting to the needs of developers in an ever-evolving tech landscape. From enabling AR experiences to powering AI-driven apps, Swift plays a crucial role in shaping the Apple ecosystem.

Whether you're a seasoned developer or someone just getting started, exploring Swift is your gateway to the vibrant Apple ecosystem. As Apple once said, "The best way to predict the future is to invent it"—and with Swift, the future is in your hands.

Installing Xcode on macOS

It’s time for us to get started and to Install the Xcode on your own Mac.

  • Visit the Mac App Store: Open the App Store and search for "Xcode." You’ll find it listed as a free download by Apple.
  • Check Your macOS Version: Ensure your macOS is updated to a version that supports the latest Xcode. Typically, this is the current or the previous major release of macOS.
  • Download and Install: Click "Get" to begin the download. At several gigabytes in size, Xcode may take some time, depending on your internet speed. Once installed, you'll find Xcode in your Applications folder.
  • Sign In to Your Apple ID: When you open Xcode for the first time, you’ll need to sign in with your Apple ID. This will enable access to essential tools like simulators and debugging capabilities.

To sign in to your Apple ID you need to choose Xcode from upper menu, than click settings, than accounts, and there with a plus button you can add new account.

Image description

Image description

Image description

Image description

💡 Pro Tip: If you’re planning to submit apps to the App Store, you’ll need an Apple Developer account, which requires an annual subscription. (but you definitely don't need that right now)

To begin exploring Xcode, let's create a project

  1. Just click on the Create New Project Button

Image description

  1. Then you'll see a large menu with different templates. Don't worry about them for now - just click on "App" since this is the basic template you'll be using most often.

Image description

  1. Next, you'll see a menu for naming your project. Don't worry - while the options might seem overwhelming at first, it's quite straightforward. Here's what to do: enter "HelloXcode" as the product name, select your team if it's available after entering your Apple ID (if not, just continue), and the organization identifier will likely auto-populate. This identifier creates a unique signature for both your organization and your app - you can see the bundle identifier below, which will be important later if you plan to publish your app. You'll then see options to choose between Storyboard or SwiftUI interface - for now, stick with Storyboard. Though I should mention that large companies rarely use Storyboard despite its convenience, as it becomes cumbersome, slows down builds, and often causes git conflicts when working with large teams on big projects. That's why most developers prefer coding interfaces manually.

    For the language option, select Swift if you see a choice between Swift and Objective-C. For Storage, leave it as None - while Core Data can generate a database for long-term data storage during and after app execution, we'll cover that in a dedicated lesson much later. Similarly, leave Include Tests unchecked since we're just getting familiar with Xcode for now - testing will be covered in its own series of lessons. With these settings selected, you can click Next.

Image description

  1. Then you can choose a folder where you'd like to save your project. Once you've decided on the location, click Create

Image description

Navigating the Xcode Interface

The Xcode interface might seem overwhelming at first, but once you understand its layout, you’ll feel right at home. Let’s break it down into some sections:

1. Workspace

Image description

The workspace is the heart of Xcode. For me, it's everything you see on the first screen when you create a project. Here you have access to project settings, and when you click on any file, its editor opens up. You can also work with various panels on the left, right, and even at the bottom of the screen. It’s where you manage files, write code, and build projects. Think of it as your coding cockpit—organized, efficient, and customizable.

  • The Project Navigator on the left displays all your project files.
  • The Toolbar at the top lets you run, stop, or select schemes for your app.

2. Editor Area (click on any file, for example ViewController)

Image description

The Editor is where you’ll spend most of your time. This area is highly dynamic and adapts to the type of file you're working on. For example:

  • Code Files: The editor shows syntax-highlighted Swift or Objective-C code.
  • UI Files: If you’re working on SwiftUI or Storyboards, the editor offers a visual design canvas.

💡 Pro Tip: Use the Assistant Editor (split view) to simultaneously view your code and its corresponding UI.

Image description

This is very convenient when working with Storyboard or when you need to view two files simultaneously, such as production code and its test version

Image description

3. Debug Area

Image description

When your app doesn’t behave as expected (and trust me, it happens to everyone), the Debug Area becomes your best friend. Located at the bottom, this section displays runtime logs, variable states, and breakpoints.

  • Use the Console Output to view logs or debug print statements.
  • Set Breakpoints to pause the execution and inspect code line by line.

We'll explore how to work with these features in future lessons. For now, just know that breakpoints let you see your app's current state when it hits a specific line of code. The left side of the console shows these objects, while the right side allows you to send commands through the console and view messages logged by you or any libraries you've included in your app.

4. Navigator

The Navigator, located on the left side of the workspace, provides quick access to different aspects of your project. Key tabs include:

  • Project Navigator: Manage files and folders.
  • Search Navigator: Quickly find functions, variables, and classes.
  • Issue Navigator: View warnings and errors to debug efficiently.

Image description

Image description

Image description

Image description

This brief overview of Xcode should suffice for now, as we'll be moving on to a different, much simpler tool that's perfect for learning Swift—Playground. We'll use Playground until we've mastered the language basics, after which we'll return to Xcode to create full-fledged applications. Trust me, this will happen sooner than you think, but for now, be patient—learning the language fundamentals is an essential step in your journey.

Introduction to Playground

Once you’ve mastered the basics of Xcode, it’s time to play—literally! Playground is an interactive feature in Xcode that lets you experiment with Swift code in real-time. It’s a fantastic way to learn the language, prototype ideas, or debug small snippets of code.

Getting Started with Playground

Create a New Playground:

  • Open Xcode, select "File" > "New" > "Playground."
  • Choose a template "Blank".
  • Find a place on Mac for you playground project and click create

Image description

Image description

Xcode will launch your Playground, displaying a split view: code on the left and results on the right.

Image description

In the section bellow you will see start and stop button, that will start your code to work and stop when needed.

If you need to view console information, look for the "Show debug area" button in the bottom-right corner. I highly recommend enabling this area early on, even if you don't need it immediately.

Image description

Why Use Playground?

  • Interactive Coding: As you write Swift code, results appear instantly. For example, if you declare a variable or perform a calculation, the outcome is displayed in the results pane.
  • Learning Swift: Playground is perfect for beginners to practice Swift concepts, from variables and loops to closures and protocols.
  • Prototyping: Test a small piece of logic without creating an entire app project. (I still use Playground from time to time even when working on large applications, as it's perfect for quickly testing new ideas)

Your First Program in Playground

Let’s write a simple program to print "Hello, world!" into the console

just put that lines of code inside your editor

import UIKit

var greeting = "Hello, world"

print(greeting)

Enter fullscreen mode Exit fullscreen mode

Image description

Hit Cmd + shift + Return (⌘ + 🔼 + ⏎), and you’ll see the output instantly in the console.

Hooray! Congratulations on creating your first program! Yes, it only prints text to the console, but this is your first step! There's much more to come!

Hey there, developers! 👨‍💻

I hope you enjoyed today’s deep dive into Xcode. If you found it helpful, I’d love your support to help grow this project further. Here’s how you can make a difference:

🌟 Follow me on these platforms:

Each follow means the world to me—it helps me reach more aspiring developers like you and motivates me to keep creating quality content!

☕ Buy Me a Coffee

If you’d like to go the extra mile, you can support me through Buy me a coffee. Your contribution fuels the creation of new lessons, tutorials, and other awesome resources. I deeply appreciate your generosity—it keeps AB Dev Hub thriving!

What’s Next?

In our next lesson, we’ll start exploring the Swift programming language itself. From variables and constants to functions and types, it’s going to be an exciting journey into the heart of app development!

Thank you for being a part of this community. Let’s keep coding, learning, and building together! 💻✨

Top comments (0)