Sitemap

Setting Up GitHub Actions for Continuous Integration

3 min readMar 31, 2025

When working on a project, keeping your builds clean and your tests passing is key to a smooth development process. In this post, I’ll guide you through setting up a GitHub Action workflow that automates building and testing your app every time you push changes to your repository.

Generated with AI

Why GitHub Actions?

Continuous Integration (CI) is an essential part of modern app development. By integrating GitHub Actions into your workflow, you can ensure that every pull request and commit is automatically built and tested — catching issues early and boosting confidence in your codebase.

Getting Started

Before diving in, make sure you have:

  • A repository already set up on GitHub (in our case, SwiftUIDeepLinking).
  • Basic familiarity with GitHub Actions and YAML syntax.
  • Xcode installed locally to verify that your project builds correctly.

Creating the Workflow File

GitHub Actions use YAML files to define workflows. In your repository, create the following directory structure if it doesn’t exist:

.github/
└── workflows/

Inside the workflows folder, create a file named ci.yml

Triggers: The on key specifies the events that will trigger the execution of your workflow. For a typical Swift project, you might want to trigger the CI process whenever code is pushed to the main branch or when a pull request is opened or updated targeting specific branches.

name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

Job Environment: This section defines one or more jobs that will be executed by the workflow. Each job has a unique identifier (e.g., build) and a more descriptive name that appears in the GitHub Actions UI (e.g., Build and Test). The runs-on key within a job definition specifies the type of virtual machine runner that will execute the job.

name: CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
name: Build and Test
runs-on: macos-latest

Steps:

Checkout Code: The workflow checks out your repository so that it can access your project files.

Set Up Xcode: Using the maxim-lobanov/setup-xcode action ensures that the correct version of Xcode is installed.

Build: This command cleans and builds your project. Adjust the -project and -scheme flags if your project structure differs.

name: CI

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
build:
name: Build and Test
runs-on: macos-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Xcode
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '16.2'
- name: Build
run: |
xcodebuild clean build \
-project Deep_Linking_with_TCA/DeepLinkTCA.xcodeproj \
-scheme DeepLinkTCA \
-destination 'platform=iOS Simulator,name=iPhone 16,OS=latest'
-skipPackagePluginValidation
-skipMacroValidation

Verifying Your Setup

Once you’ve committed the ci.yml file, navigate to the Actions tab in your GitHub repository. You should see your workflow listed and running on your next push or pull request. Any build or test errors will be displayed there, making it easier to catch issues early. Here is the link to the final ci.yml file.

Conclusion: Taking Your Swift CI/CD to the Next Level

Setting up a CI/CD pipeline for your Swift project using GitHub Actions offers numerous benefits, from improved code quality and reduced manual effort to faster feedback loops and accelerated development cycles. By automating the build and test processes, you can ensure that your codebase remains stable and reliable with every change.

--

--

Saeid Rezaeisadrabadi
Saeid Rezaeisadrabadi

Written by Saeid Rezaeisadrabadi

Over 8 years of experience in iOS software development

No responses yet