Development with CI/CD and GitHub Actions on iOS project

Alba Torres
3 min readSep 27, 2023

--

I have started learning iOS development using SwiftUI and as part of my learning, I decided to set up a workflow to run Xcode tests using GitHub Actions. Today, I want to share my experience of doing it 😊 .

What is CI/CD?

Continuous Integration and Continuous Deployment (CI/CD) is a set of practices that aim to streamline the software development lifecycle. It revolves around the automation of building, testing, and deploying code changes to production. The core principles of CI/CD include frequent code integration, automated testing, and rapid and reliable deployments. This approach enhances code quality, accelerates development, and minimizes the risk of errors in production.

What is GitHub Actions?

GitHub Actions is a powerful automation tool provided by GitHub. It enables developers to create custom workflows that automate various tasks, such as building, testing, and deploying code, directly from their GitHub repositories. GitHub Actions integrates seamlessly with your existing workflow and allows you to automate repetitive tasks efficiently.

Why Use Workflows?

Workflows are at the heart of GitHub Actions, and they are essential for your CI/CD processes. Here’s why they are crucial:

  • Automation 🛠️ : Workflows automate repetitive tasks, saving developers time and reducing manual errors.
  • Consistency 🪨 : Workflows ensure that every code change goes through the same set of checks and tests, maintaining a consistent and high-quality codebase.
  • Visibility 👀 : Workflows provide visibility into the progress of code changes, making it easier to identify issues early in the development process.
  • Scalability 📶 : As your project grows, workflows can be easily scaled to accommodate new requirements and maintain efficient development practices.

Implementation: Build, Test, and Block on Failure

Let’s take a practical example of implementing a CI/CD workflow using GitHub Actions. In this case, we aim to build 🏗️ and test an iOS SDK project, and if any test fails, we want to block the PR merge.

Here’s a simplified version of the workflow script:

In this script:

  • We define a GitHub Actions workflow triggered by pushes to the repository.
  • The workflow runs on a macOS-latest runner 💻.
  • It then builds and tests the iOS SDK using Xcode.
  • The exit status of the tests is captured, and if any test fails, the workflow exits with an error, blocking the PR merge 🚦.

This workflow ensures that code changes are rigorously tested, and only if all tests pass, the PR can be merged, maintaining the integrity of the codebase 🦾.

In conclusion, CI/CD and GitHub Actions have become indispensable tools in modern software development. By automating tasks and implementing workflows like the one described above, development teams can save time, improve code quality, and confidently deliver reliable software to their users.

I hope this article helped someone. Happy coding!

--

--