How do I update the Ruby version for iOS builds on Codemagic?

Last updated: June 29, 2026

Context

When building iOS projects on Codemagic, you may encounter issues with Ruby version compatibility. Some developers try to update the Ruby version by modifying the Podfile or setting environment variables, but these approaches may not work as expected. The Ruby version on Codemagic is determined by the build machine image, which is selected based on the Xcode version you specify.

Answer

There are two ways to control the Ruby version in your codemagic.yaml:

Option 1: Pin the Xcode version

Codemagic selects a build machine image based on the Xcode version, and each image comes with a specific Ruby version preinstalled. Simply set:

environment:  
  xcode: 26.2

Option 2: Specify the Ruby version directly

If you need a Ruby version that differs from the default for your chosen Xcode image, you can specify it explicitly:

environment:  
  ruby: 3.3.6

Why this works:

  • The Ruby version depends on the build machine image

  • The build machine image is selected by the Xcode version you specify

  • Different Xcode versions come with different Ruby versions preinstalled

  • Setting ruby explicitly lets you use a version not bundled with your chosen Xcode image

For reference, you can check the build machine specifications:

This approach is more reliable than hard-coding Ruby versions and ensures your builds use a consistent environment.