How to Run CocoaPods on Apple Silicon (M1)

How to Run CocoaPods on Apple Silicon (M1)

6 June 2024 Stephan Petzl Leave a comment Tech-Help

Transitioning to an Apple Silicon (M1) Mac can introduce several challenges, especially when running development tools originally designed for Intel-based systems. One common issue developers face is running CocoaPods on an M1 Mac, particularly when working on Flutter projects targeting iOS. This guide provides a step-by-step solution to help you successfully install and run CocoaPods on your Apple Silicon device.

Solution Overview

Follow these steps to install CocoaPods on your M1 Mac:

  1. Uninstall the local CocoaPods gem:
  2. sudo gem uninstall cocoapods
  3. Reinstall CocoaPods via Homebrew:
  4. brew install cocoapods

Additional Steps for Troubleshooting

If you encounter issues with the above steps, consider the following troubleshooting tips:

  • Install ffi gem: If you see an error related to ffi, you can install the ffi gem using the following command:
sudo arch -x86_64 gem install ffi
  • Re-install dependencies: After installing the ffi gem, re-install your CocoaPods dependencies:
  • arch -x86_64 pod install
  • Set an alias: If you frequently run pod commands, setting up an alias in your shell configuration file (.zshrc or .bash_profile) can save time:
  • alias pod='arch -x86_64 pod'

    Alternative Ruby Installation

    For a more permanent solution, consider installing a version of Ruby specifically built for ARM64. Here’s how to do it using Homebrew:

    1. Install Ruby:
    2. brew install ruby
    3. Add Ruby and gems binaries to your PATH:
    4. export PATH=/opt/homebrew/opt/ruby/bin:/opt/homebrew/lib/ruby/gems/3.0.0/bin:$PATH
    5. Source your shell configuration:
    6. source ~/.zshrc
    7. Install CocoaPods:
    8. sudo gem install cocoapods
    9. Verify Ruby and CocoaPods installation:
    10. which ruby
      which pod

    Conclusion

    By following these steps, you should be able to run CocoaPods on your M1 Mac without issues. Whether you choose to use Homebrew for a more streamlined installation or manually configure your environment, these solutions will help you get your development workflow back on track.

    Streamline Your Mobile Development with Repeato

    As a mobile developer, ensuring your applications run smoothly across different environments is crucial. Repeato, our No-code test automation tool for iOS and Android, can help you achieve this effortlessly. Repeato allows you to create, run, and maintain automated tests for your apps quickly and efficiently, leveraging computer vision and AI. This enables you to focus on developing great features while leaving the testing process to Repeato. Additionally, it allows non-technical colleagues or QAs to participate in the testing process, ensuring a comprehensive and collaborative approach to quality assurance.

    Learn more about Repeato and how it can enhance your development process by visiting our documentation and blog.

    Like this article? there’s more where that came from!