## TL;DR

Add a pre-build script that uninstalls the default CocoaPods (gem uninstall cocoapods --all) and installs the exact version the lockfile needs (gem install cocoapods -v [version]), then runs pod install in the ios directory. Keep the pinned version in sync with the lockfile when you upgrade locally.

## Steps

1. Add a pre-build script that uninstalls the default CocoaPods (gem uninstall cocoapods --all) and installs the exact version the lockfile needs (gem install cocoapods -v [version]), then runs pod install in the ios directory. Do this before the build step so the right version is active. Keep the pinned version in sync with the lockfile when you upgrade locally.

## When to use

You are seeing this: Do this before the build step so the right version is active. Use this skill when you run into "Pin a specific CocoaPods version on Codemagic".

## When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

## Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

## Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.
