The 30-Second Fix
If you are in the middle of a sprint and just need to get pod install working immediately, force the command to run through the Rosetta 2 translation layer. This side-steps the architecture conflict by emulating an Intel environment.
sudo arch -x86_64 gem install ffi
arch -x86_64 pod install
This tells your Mac to treat these specific commands as if they are running on an older Intel machine. It usually resolves the symbol mismatch instantly.
Why This Happens
The error stems from a "handshake" failure between your Ruby interpreter and the ffi (Foreign Function Interface) gem. The specific symbol _ffi_prep_closure_loc belongs to the libffi library.
Modern Macs use the ARM64 architecture, but many developer tools still rely on x86_64 (Intel) binaries. This error triggers when CocoaPods tries to load an Intel-compiled version of ffi while Ruby is running natively on ARM64. Because the architectures don't match, the dynamic linker (dyld) cannot find the required symbols in the "flat namespace." It's essentially a language barrier at the binary level.
Permanent Solutions
Method 1: Native Reinstallation
The cleanest approach involves rebuilding the ffi gem specifically for your Mac's native ARM64 chips. This removes the need for Rosetta entirely.
- Wipe the old gem:
sudo gem uninstall ffi
- **Reinstall with native compiler flags:**
```
sudo gem install ffi -- --with-cflags="-Wno-error=implicit-function-declaration"
Using the -Wno-error flag is crucial here. Newer versions of Xcode treat implicit function declarations as errors, which can block the ffi installation on macOS 14 (Sonoma) or 15 (Sequoia).
- Verify the install:
pod install
### Method 2: The Rosetta Bridge
Sometimes your project has legacy dependencies that simply won't run on ARM64. In that case, you should run your entire CocoaPods stack through Rosetta. First, make sure Rosetta 2 is actually on your system:
softwareupdate --install-rosetta
Once installed, prefix your installation commands like this:
sudo arch -x86_64 gem install ffi arch -x86_64 pod install
Stop typing long commands. Add an alias to your `.zshrc` file to save time:
alias rpod='arch -x86_64 pod install'
### Method 3: Use a Ruby Version Manager (Highly Recommended)
The default "system" Ruby provided by Apple is notoriously difficult to manage. It often triggers permission errors (requiring `sudo`) and architecture conflicts. Tools like `rbenv` or `asdf` let you install a dedicated, native ARM64 Ruby environment in your user directory.
- **Grab rbenv via Homebrew:**
```
brew install rbenv ruby-build
- Install a modern, native Ruby (e.g., 3.3.1):
rbenv install 3.3.1 rbenv global 3.3.1
- **Refresh your shell and reinstall your tools:**
```
gem install cocoapods ffi
pod install
Gems installed via rbenv are compiled against your specific Ruby version. This setup almost always eliminates dlsym symbol errors for good.
Testing the Results
Confirm your environment is healthy with these three quick checks:
- CPU Architecture: Run
ruby -e "puts RbConfig::CONFIG['host_cpu']". It should returnarm64for native mode. - Command Success: Run
pod --version. If it prints a version number (like 1.15.2) without a crash, you are in the clear. - Final Install: Run
pod install. You want to see the green "Pod installation complete" message.
Hidden Traps
Terminal Settings: Open Finder, go to Applications > Utilities, and right-click your Terminal (or iTerm2). Select Get Info. Ensure "Open using Rosetta" is unchecked if you want a native ARM64 workflow. If this is checked, every command you run will be slowed down by Intel emulation.
Homebrew Paths: Check your paths. ARM64 Homebrew lives in /opt/homebrew, while the old Intel version lives in /usr/local. If your $PATH points to /usr/local/bin first, you might be accidentally using Intel-based tools on your native Mac.

