April 28, 2023

Accelerate iOS and MacOS Build Pipelines with Apple M1 and Harness

Table of Contents

Key takeaway

We're excited to announce Apple Silicon M1 support in the Harness Continuous Integration (CI) module, enabling faster and more efficient iOS build pipelines. 

Apple marked a significant shift in the hardware architecture of its Mac devices when it introduced the M1 chip in 2020. The M1 chip offers major performance improvements over Apple's previous Intel processors, especially in areas such as processing speed, power efficiency, graphics performance, and machine learning. For iOS developers, the potential for faster and more efficient app development has never been greater, and mobile teams are already seeing faster build times when using M1.

At Harness, we recognize the importance of speed and efficiency in CI/CD. To meet this need, we have incorporated M1 machines into our system, enabling our customers to take advantage of the exceptional performance of M1 machines. By combining this powerful hardware with the Harness Cloud infrastructure (our fully managed cloud service offering), developers can optimize their workflow and reduce build times like never before. 

In this blog, we'll explore how to use M1 machines in CI/CD pipelines,  configure your pipeline to run on our Cloud M1 machines, and build a macOS app using a demo project. Whether you're an iOS developer looking to optimize your workflow or simply curious about how to take advantage of M1 machines for your CI/CD pipelines, this blog is for you.

Using an M1 Machine 

To configure your CI stage to run on our Cloud M1 machines, simply set the stage’s ‘platform’ property to execute on macOS using ‘ARM64’ architecture. For example:

stages:
    - stage:
        name: build
        identifier: build
        type: CI
        spec:
          cloneCodebase: true
          platform:
            os: MacOS         // selects macOS operating system
            arch: Arm64       //selects M1 architecture
          runtime:
            type: Cloud
            spec: {}
          execution:
            steps:
              …

As an iOS developer, you may need to select a specific Xcode version for building your app.  When using Harness Cloud, the machines come equipped with preinstalled software that you can instantly leverage, including multiple xcode versions. The following command can be used to select any of the available Xcode versions on the machine:

 sudo xcode-select -switch /Applications/Xcode_[version].app  

For example, the following step sets the machine to use Xcode version 13.4.1 rather than the machine’s default version.  

- step:
  type: Run
  name: set xcode version
  identifier: set_xcode_version
  spec:
      shell: Sh
      command: |
          sudo xcode-select -switch /Applications/Xcode_13.4.1.app
          xcodebuild -version  // verify selected version 

What if I Need to Use Intel-based architecture?

As an iOS developer, you may need to use Rosetta if you are working with apps or tools that have not yet been updated to run natively on Apple Silicon. Rosetta is a technology developed by Apple to bridge the compatibility between Intel and Apple silicon processors. It allows you to run apps that contain x86_64 instructions on Apple Silicon machines.

Rosetta is installed and enabled by default on Harness Cloud M1 machines. To use it, add the "arch -x86_64" prefix in front of each command you run in your scripts. This tells the system to use x86_64 instructions.

Although Rosetta can be a valuable tool for iOS developers, it is important to note that running apps through Rosetta may impact performance. Therefore, it’s recommended to use native Apple Silicon apps whenever possible to ensure optimal performance.

Try it Yourself 

  • Fork the sample repository https://github.com/CIsamples/macos_demo into your account.
  • Sign up for a free account (or log in to an existing account)
  • Follow the Get Started wizard in Harness CI.
  • Configure connection to your Source Code Manager
  • When you are prompted to select a Source Control Manager, select ‘GitHub’ and use either OAuth or Access Token as the authentication method that Harness CI will use to connect to your GitHub account.
  • When you are prompted to select a repository, select the repository that you forked in the earlier step, and then select Configure Pipeline.
  • Select ‘Create empty pipeline configuration’ and then select Create Pipeline.
  • After following these steps, you will have a basic ‘hello world’ pipeline that clones your forked repository and prints a welcome message.
  • Select MacOS as your build infrastructure  
  • Replace the ‘echo’ command with ‘xcodebuild’ 

You will have a pipeline similar to the following: 

pipeline:
  name: Build MacOS demo
  identifier: Build_macos_demo
  projectIdentifier: default_project
  orgIdentifier: default
  stages:
    - stage:
        name: build
        identifier: build
        type: CI
        spec:
          cloneCodebase: true
          platform:
            os: MacOS         // selects macOS operating system
            arch: Arm64       //selects M1 architecture
          runtime:
            type: Cloud
            spec: {}
          execution:
            steps:
              - step:
                  type: Run
                  name: Run xcodebuild
                  identifier: Run_xcodebuild
                  spec:
                    shell: Sh
                    command: xcodebuild


Get Started with M1 and Harness

Incorporating Apple Silicon M1 machines into your CI/CD pipeline can lead to faster build times and more efficient app development. With the Harness Cloud infrastructure, utilizing M1 machines has never been easier. We hope this blog has been helpful in providing you with the necessary tools to optimize your workflow and take advantage of the exceptional performance offered by Apple Silicon M1 machines.

Ready to get started with Harness CI/CD? Sign up for a free trial today!

You might also like
No items found.

Similar Blogs

No items found.
Continuous Integration