Solved by these steps:
Removed pods and Podfile.lock, clear DerivedData and clean build
rvm use 3.4.5
bundle install
bundle exec pod install --repo-update
gem install ffi -- --enable-libffi-alloc (for my M1 chip)
gem install ffi -- --enable-libffi-alloc