If you are building a flutter application for apple processors using Silicon processors (M1+) and dealing with native packages for things such as playing a sound, you maybe encountered this error:
Error output from CocoaPods:
↳
/System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': cannot load such file --
ffi_c (LoadError)
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /Library/Ruby/Gems/2.6.0/gems/ffi-1.17.0-x86_64-darwin/lib/ffi.rb:5:in `rescue in <top (required)>'
from /Library/Ruby/Gems/2.6.0/gems/ffi-1.17.0-x86_64-darwin/lib/ffi.rb:2:in `<top (required)>'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
from /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require'
...
Error: To set up CocoaPods for ARM macOS, run:
sudo gem uninstall ffi && sudo gem install ffi -- --enable-libffi-alloc
You probably realised that running sudo gem uninstall ffi && sudo gem install ffi -- --enable-libffi-alloc
will not work. You are going to get the same error.
The solution I found was to use cocoapods from brew.
For that, run:
sudo gem uninstall cocoapods
brew install cocoapods
brew link cocoapods
Last thing, as I am quite new to flutter and some of the Apple ecosystem, if anyone has a better suggestion, I am all ears.
Link to the author blog: Using flutter with native resources on apple silicon processors
Top comments (0)