Loading... Search articles

Search for articles

Sorry, but we couldn't find any matches...

But perhaps we can interest you in one of our more popular articles?
Updating your dependencies for Apple Silicon M1 & M2 Macs and CI/CD.

Updating your dependencies for Apple Silicon M1 & M2 Macs and CI/CD

May 18, 2022

This article is written by Rudrank Riyam

This article has been updated in May, 2023 to include Mac mini M2 information.

Use M1 Mac mini VMs by default with Codemagic🚀 Build faster

TL;DR: This article covers how to update dependencies for Homebrew, CocoaPods, Carthage, Ruby, and more if you are using Apple Silicon Macs. However, for the Mac mini M2s and M1s available on Codemagic, you don’t have to do anything described in this article — everything is already preinstalled and preconfigured, so you can just use them right away.

We’ve already started talking about migrating your CI/CD to Apple Silicon M1 & M2 Macs' and covered the basics, such as requirements and updating basic dependencies — you can read the blog post on this here. It also covers the reasons why you should even care about migrating to M1s. In this article, we’ll dive somewhat deeper into the topic of updating dependencies and package managers for Apple Silicon M1 & M2 Macs.

This article covers the following topics:

  • Updating Homebrew
  • Updating Ruby
  • Updating RubyGems
  • Updating CocoaPods
  • Updating Carthage

Let’s get started!

Updating Homebrew

Homebrew is a popular package manager that helps you to simplify installing tools and software on your Mac machine. You can use it to install Ruby, dependency managers like CocoaPods and Carthage, or the popular automation tool fastlane.

Homebrew is one of the recommended dependency managers. You may require versions of tools built specifically for arm64 architecture, e.g., Ruby.

The default path for Homebrew has changed for the new Apple Silicon machines, and you may need to update the path for Homebrew in your local machine and the path in your Codemagic workflow if you are using hard-coded paths. This was announced back in January 2021, when /opt/homebrew became the default directory for Apple silicon instead of /usr/local on the Intel machines.

At the time of writing this article (May 2023), most of the popular tools that use Homebrew already support the arm64 architecture, so it’s easier to update different software using Homebrew.

The default shell in macOS Big Sur and Monterey is zsh. You can check which shell program is running in your terminal with the following command:

echo $SHELL

If you do not have Homebrew installed, you can run the following command in the terminal:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

Homebrew is already installed on the M1 Mac minis and other machines available on Codemagic. You are not required to add this command to your workflow configuration file for it.

The command above will install Homebrew — however, you’ll get a warning:

Warning: /opt/homebrew/bin is not in your PATH.
  Instructions on how to configure your shell for Homebrew
  can be found in the “Next steps” section below.
==> Installation successful!

You will be instructed to run two commands in your terminal to add Homebrew to your PATH:

echo 'eval $(/opt/homebrew/bin/brew shellenv)' >> ~/.zprofile
eval $(/opt/homebrew/bin/brew shellenv)

The path has already been updated for the M1 Mac mini build machines available on Codemagic, so you do not have to explicitly write a command or script.

After running these two commands, make sure to either restart the terminal app or execute the following:

source ~/.zshrc

You can confirm that the new path has been set by running the following command:

which brew

The output should look something similar to this:

rudrankriyam@Rudrank-2 ~ % which brew

For Intel machines, the path looks something like this:

rudrankriyam@Rudrank ~ % which brew

To confirm that everything is ready for your Apple silicon machine, run the following command:

brew doctor

If everything is working fine, the output should be similar to this:

rudrankriyam@Rudrank-2 ~ % brew doctor                                                  
Your system is ready to brew.

Note that if you forget to change the path for Homebrew, it will still allow you to install some other packages, but they will have the wrong path too. This may result in them not working correctly.

With Homebrew set up for your Apple Silicon machine, updating other packages is going to be a breeze!

Updating Ruby

Ruby is a dynamic, high-level programming language that focuses on simplicity and productivity. It has an elegant syntax that is natural to read and easy to write. More often than not, the tools you use for your iOS projects are written in Ruby. Hence, it’s important to update Ruby to the latest version that supports the arm64 architecture.

Homebrew is a package manager that is commonly used on macOS for installing Ruby:

brew install ruby

This command installs the latest Ruby version.

Make sure you have already updated the path mentioned in the previous section on Updating Homebrew.

Then you can check the version of Ruby installed on your machine:

ruby -v

You will get the following response:

rudrankriyam@Rudrank-2 ~ % ruby -v          
ruby 3.1.2p20 (2022-04-12 revision 4491bb740a) [arm64-darwin21]

As you can see, arm64-compatible Ruby is installed for the current device.

Ensure that Ruby is installed in the correct path:

which ruby

The output should look something like this:

rudrankriyam@Rudrank-2 ~ % which ruby

The path on an Intel machine used to look like this:

rudrankriyam@Rudrank ~ % which ruby

If it still shows the pre-installed Ruby after following the above steps:

rudrankriyam@Rudrank ~ % which ruby

You can explicitly set the path for Ruby:

export PATH=/opt/homebrew/opt/ruby/bin:$PATH

Ruby is already installed on the Mac mini M2 and M1, which is available on Codemagic. If you require the latest version of Ruby, you can add the install script to your workflow configuration file.

Updating RubyGems

RubyGems is a package management framework for Ruby. If you already installed Ruby in the previous step, you can check if it is installed correctly in the correct path with the following command:

which gem 

The output should look something like the following:

rudrankriyam@Rudrank-2 ~ % which gem                                           

As Ruby is already installed on the Mac mini M2s and M1s, which are available on Codemagic, RubyGems is also installed.

If you want to update RubyGems to the latest version, run the following command:

gem update --system

This package manager for Ruby can be used to install different gems (Ruby packages). For example, Ruby-FFI is a gem for programmatically loading dynamically linked native libraries, binding functions within them, and calling them from Ruby code. You may use this gem for libraries in your iOS projects.

To install it correctly on your Apple silicon machine, you have to use the following command:

gem install --user-install ffi -- --enable-libffi-alloc

Using the install option --enable-libffi-alloc forces closure allocation by libffi. If you were getting errors or segmentation faults earlier while working with this popular gem, installing it this way is a potential solution for machines with arm64 architecture.

For example, Jazzy is a command-line utility that generates documentation for Swift or Objective-C code. You install it using RubyGems, and the utility uses Ruby-FFI. Developers were facing issues with fii, and installing it using the command above fixed it.

Updating CocoaPods

CocoaPods is a dependency manager for Swift and Objective-C Cocoa projects. You may be using it in your iOS project, so updating it correctly for Apple Silicon machines is essential. If you have followed the process above to update Homebrew and Ruby, then installing CocoaPods is a one-line command:

brew install cocoapods

The latest version of CocoaPods is already installed on the Mac mini M2 and M1, which are available on Codemagic. You are not required to add this command to your workflow configuration file.

Then you can ensure that it is installed in the correct path:

which pod

The output should look something like this:

rudrankriyam@Rudrank-2 ~ % which pod

For an Intel machine, the path looks like this:

rudrankriyam@Rudrank ~ % which pod

Then, you can install the pods in your projects for the arm64 architecture:

pod install

You can easily use pods in your project now when running on an Apple silicon Mac! If you have issues updating particular pods, look at the section on updating third-party dependencies in this article.

Updating Carthage

Carthage is a simple dependency manager for your iOS and macOS projects. It builds third-party dependencies and provides you with binary frameworks, giving you total control over the project structure.

Similar to CocoaPods, you can use Homebrew to install Carthage:

brew install carthage

Then you can ensure that it is installed in the correct path:

which carthage

The output should look similar to the following:

rudrankriyam@Rudrank-2 ~ % which carthage

For an Intel machine, the path looks like this:

rudrankriyam@Rudrank ~ % which carthage

At this point, you will find that third-party libraries and frameworks offer XCFrameworks, which is required when building on an Apple silicon Mac. You can use XCFrameworks by running the following command:

carthage update --use-xcframeworks

If you are switching from discrete framework bundles to XCFrameworks, follow the migration steps mentioned by Carthage here.

Build times for Mac mini M2, Mac mini M1 and Intel Mac Pro

You can take inspiration from open-source projects that have been successfully migrated and work on the new chips. Take a look at a few examples of such projects here.

To appreciate the build time differences between the Apple Silicon and Intel machines and gain a clearer understanding of the enhanced efficiency and speed offered by the Mac mini M2 and Mac mini M1, we conducted tests on the official Wikipedia iOS app. This experiment presents you with a real-world scenario involving hundreds of tests. As an open-source app, you are welcome to explore it yourself.

Test name Mac mini M2 Mac mini M1 Mac Pro
Installing scripts 7s 11s 17s
Building project 81s 115s 188s
Running tests 139s 219s 345s
Overall 310s 428s 716s

You can see the significant differences in the numbers, especially while running tests — they execute much more quickly on the Apple Silicon build machines. We observe a reduction of 35–40% in overall build times when comparing the Mac mini M2 to Intel Mac Pro. This gap accumulates when executing numerous builds, which you may do on a daily basis, ultimately saving a significant amount of time and providing a faster iteration process.


Updating the tools and packages ensures that you are taking advantage of the raw power of Apple silicon instead of using Rosetta 2 emulation.

Apple silicon chips are the future of Mac hardware, and it only gets better from here on out. Most package managers and tools already support the new chips, so the transition is much easier than it was a year ago.

Reminder: Mac mini M1 build machines are already available on Codemagic as the default machine type. In order to try out the new Mac mini M2, contact our customer engineering team. Get on the Apple Silicon machines for faster green builds! 🟢

How did you like this article?

Oops, your feedback wasn't sent

Related articles

Latest articles

Show more posts