❓ What is this?
When building for iOS in Unity, I kept getting the error message below.
This post walks through how I fixed it.
Error building Player: iOS framework addition failed due to a CocoaPods installation failure. This will will likely result in an non-functional Xcode project.

💻 Environment
- Chip Apple M1
- Memory 16 GB
- macOS Sonoma 14.5 (23F79)
- Unity Version 2022.3.31f1
💡 Steps to resolve it
Nothing I tried was working, so in the build folder I ran
pod install
but I got the following error
cannot load such file — ffi_c (LoadError)
However, when I checked with
gem list
the ffi entry was indeed there….
So I uninstalled it with the command below and reinstalled it.
sudo gem uninstall ffi && sudo gem install ffi -- --enable-libffi-alloc
And that fixed it!! So glad 😭
💪 Things I tried
Here's a list of everything else I tried. None of them turned out to be the decisive fix. (Though maybe one of them helped somehow…?)
Updating Ruby
Installing the latest Ruby
brew install ruby
Setting the environment variable
echo 'export PATH="/usr/local/opt/ruby/bin:$PATH"' >> ~/.zshrc source ~/.zshrc
Installing LibYAML
A library for handling YAML files easily in C.
brew install libyaml
psych is a Ruby library for parsing and generating YAML data.
sudo gem install psych
Installing cocoapods
There was a YouTuber overseas who got it working this way. (It didn't work for me…)
sudo arch -x86_64 gem install ffi
arch -x86_64 pod install
Reinstalling CocoaPods
Uninstalling CocoaPods
sudo gem uninstall cocoapods
Installing CocoaPods
sudo gem install cocoapods
Cleaning up dependencies
pod cache clean --all
Clearing the CocoaPods cache
Clearing the cache
rm -rf ~/Library/Caches/CocoaPods
rm -rf Pods
rm -rf ~/Library/Developer/Xcode/DerivedData/*
pod deintegrate
pod setup
📕 Reference
CocoaPods installation
https://cocoapods.org