TASIOMIND.DEV — OPERATIONAL▸▸▸FULL STACK DEVELOPER @ GWQ SERVICEPLUS AG▸▸▸FOUNDER — K8SGPT.AI▸▸▸OPEN SOURCE: ACTIVE▸▸▸DISTRIBUTED SYSTEMS / KUBERNETES / AI▸▸▸RUST + GO + PYTHON▸▸▸FIELD TESTED / STATUS — NOMINAL▸▸▸LOCATION: EUROPE/BERLIN▸▸▸TASIOMIND.DEV — OPERATIONAL▸▸▸FULL STACK DEVELOPER @ GWQ SERVICEPLUS AG▸▸▸FOUNDER — K8SGPT.AI▸▸▸OPEN SOURCE: ACTIVE▸▸▸DISTRIBUTED SYSTEMS / KUBERNETES / AI▸▸▸RUST + GO + PYTHON▸▸▸FIELD TESTED / STATUS — NOMINAL▸▸▸LOCATION: EUROPE/BERLIN▸▸▸

Install Ruby with rbenv and CocoaPods on M1 MacBook (Apple Silicon)

June 20, 2021

  1. install Homebrew
  2. Install Ruby with rbenv
  3. Install CocoaPods

Doing your own Ruby installation instead of using the system one is preferred, either with Homebrew or rbenv. Apple is deprectaing the default system installation of Ruby anyway.

Homebrew, rbenv and Ruby

code
# install homebrew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"

# install ruby with rbenv
brew install rbenv # ruby-build is included
rbenv install 3.0.1
rbenv global 3.0.1 # set system default ruby version

ruby -v
# ruby 3.0.1p64 (2021-04-05 revision 0fb782ee38) [arm64-darwin20]
code
rbenv install -l # list versions that can be installed
rbenv versions # list installed ruby versions
rbenv global 3.0.1 # set system default ruby version

Cocoapods

code
gem install ffi cocoapods
rbenv rehash # run a rehash after installing gems (or a new Ruby version) to make sure everything new is on your PATH:
  • sudo is not needed for Ruby versions installed with rbenv
  • ffi is needed here to get rid of some ffi related LoadError
  • rbenv rehash is important, otherwise the Podfile will keep using the old system installed Ruby

Now you can go to your iOS project and do pod repo update && pod install

Troubleshooting

  • if you're getting errors about versions not found or mismatched versions..
code
rm -rf ./Podfile.lock
  • if you have a real old project and the an old install of CocoaPods, you can delete the CocoaPods repo cache and update it again
code
sudo rm -rf ~/.cocoapods/repos
pod repo update
  • i was getting the following error when doing a pod install inside an iOS project with Ruby installed with Homebrew and an old CocoaPods installation. The issue is not with FFI library and the error went away with this fresh install of Ruby and CocoaPods
code
LoadError - dlopen(/Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi_c.bundle, 0x0009): missing compatible arch in /Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi_c.bundle - /Library/Ruby/Gems/2.6.0/gems/ffi-1.14.2/lib/ffi_c.bundle