Complete Solution for Running CocoaPods on Apple Silicon (M1)

Nov 12, 2025 · Programming · 13 views · 7.8

Keywords: Apple Silicon | CocoaPods | M1 Mac | ffi error | Rosetta | architecture compatibility

Abstract: This article provides a comprehensive analysis of the ffi_c.bundle symbol not found error when running CocoaPods on Apple Silicon M1 Macs. It offers systematic solutions based on best practices, including installing Rosetta, using architecture-specific gem commands to install the ffi library, and reinstalling pod dependencies to effectively resolve architecture compatibility issues. The article also explores the root causes of the error, compares different solution approaches, and provides practical configuration recommendations.

Problem Background and Error Analysis

When running iOS builds for Flutter projects on Apple Silicon M1 Mac devices, developers frequently encounter CocoaPods installation failures. The error message typically shows: LoadError - dlsym(0x7f8926035eb0, Init_ffi_c): symbol not found - /Library/Ruby/Gems/2.6.0/gems/ffi-1.13.1/lib/ffi_c.bundle. This error stems from architecture compatibility issues, where the M1 chip uses ARM64 architecture while the system's built-in Ruby environment and related gem libraries may not be properly adapted.

Core Solution

Based on community-verified best practices, resolving this issue requires three key steps:

Step 1: Enable Rosetta Support

Although M1 Macs natively support ARM64 applications, certain toolchains still require x86_64 architecture compatibility. Enable Rosetta mode for Terminal by:

  1. Right-clicking the Terminal application in Finder
  2. Selecting "Get Info"
  3. Checking the "Open using Rosetta" option

Step 2: Install ffi Gem Library

The ffi (Foreign Function Interface) library is a critical dependency for CocoaPods and needs to be installed for the correct architecture:

sudo arch -x86_64 gem install ffi

This command uses the arch -x86_64 prefix to ensure gem installation occurs under x86_64 architecture, preventing symbol lookup errors.

Step 3: Reinstall Pod Dependencies

After completing ffi installation, re-run the pod installation command with the same architecture prefix:

arch -x86_64 pod install

Technical Principles of the Solution

The root cause of this error lies in the mismatch between Ruby's RbConfig configuration information and the actual architecture of the M1 chip. The system's built-in Ruby environment may have been built with incorrect CPU architecture information, causing dynamic library loading failures.

By using the arch -x86_64 prefix, we force commands to run in x86_64 compatibility mode, which ensures:

Alternative Solution Comparison

In addition to the primary solution, the community has proposed other methods:

Homebrew Installation Approach

Install separate Ruby environment and CocoaPods via Homebrew:

sudo gem uninstall cocoapods
brew install cocoapods

This method provides cleaner dependency management but requires additional environment configuration.

Complete Ruby Environment Replacement

Install Ruby versions specifically built for ARM64 architecture:

brew install ruby
export PATH=/opt/homebrew/opt/ruby/bin:/opt/homebrew/lib/ruby/gems/3.0.0/bin:$PATH
sudo gem install cocoapods

This is the most thorough solution but has higher configuration complexity.

Practical Configuration Recommendations

For developers who frequently use pod commands, it's recommended to add an alias in shell configuration files:

alias pod='arch -x86_64 pod'

Adding this line to ~/.zshrc or ~/.bash_profile avoids the need to type the architecture prefix every time.

Future Compatibility Considerations

As the Apple Silicon ecosystem matures, these compatibility solutions will gradually become unnecessary. However, at the current stage, using Rosetta and architecture-specific installation commands remains the most stable and reliable approach. Developers should monitor official updates from the CocoaPods and Ruby communities and migrate to native ARM64-supported environments in a timely manner.

Conclusion

The key to successfully running CocoaPods on Apple Silicon M1 Macs lies in properly handling architecture compatibility issues. By enabling Rosetta support, using the arch -x86_64 prefix to install the ffi library, and reinstalling pod dependencies, developers can quickly resolve symbol not found errors and ensure normal building and running of Flutter projects.

Copyright Notice: All rights in this article are reserved by the operators of DevGex. Reasonable sharing and citation are welcome; any reproduction, excerpting, or re-publication without prior permission is prohibited.